May 8, 2006 at 7:24 am
I hope someone can help me with this. I'm trying to do some concatenation in a stored procedure. I have in an Access query this string.
MyAACol: "AA" & [Org] & "00" & [Acct_Nbr] & [Tran_Code] & [Amount]
The variables "AA" and "00" are not actual fields in the table but text I want to include in the string. The name of the field wil be MyAACol. How this same thing be accomplished in a stored procedure?
May 8, 2006 at 9:14 am
"+" is the string concatenation operator in T-SQL. If the table columns aren't character, you'll have to CAST them.
Greg
Greg
May 9, 2006 at 7:18 am
Also, you want to use single quotes instead of double quotes.
So, assuming Tran_Code and Amount are numeric data types and the others are not:
('AA' + [Org] + '00' + [Acct_Nbr] + CAST([Tran_Code] as varchar(10)) + CAST([Amount] as varchar(30)) ) AS MyAACol
May 9, 2006 at 7:56 am
and null ''
null + 'any string' = null
you will have to use the ISNULL() function which is simillar to the NZ() function in ACCESS.
ISNULL(null,'') + 'any string' = 'any string'
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy