January 22, 2002 at 2:22 pm
In SQL, since we use single quotes to mark the beginning and end of character strings, we have to double up the single quotes when we intend for single quotes to be part of the SQL string. For instance:
SET @s-2 = 'SELECT @table = ''abc'' '
This should set @s-2 equal to:
SELECT @table = 'abc'
K. Brian Kelley
http://www.sqlservercentral.com/columnists/bkelley/
Edited by - bkelley on 01/22/2002 2:22:58 PM
K. Brian Kelley
@kbriankelley
January 22, 2002 at 2:52 pm
Also got another quick question about the same thing. If I want to print the @col which is a variable itself how can I get it?
I have @col dynamically assigned from syscolumns as say abc. Now the next stmmt I want it to be assigned to another var so I can use it for another purpose.
@col = 'abc'
select @s-2 = 'select @col_name = ''+ @col+'' '
print @s-2
When I do this all I get is
select @col_name = '+ @col+' and not
select @col_name = 'abc'
Thanks
January 22, 2002 at 3:23 pm
Yes, it looks like you've got the hang of it!
K. Brian Kelley
http://www.sqlservercentral.com/columnists/bkelley/
K. Brian Kelley
@kbriankelley
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply