Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 is it possible to have ' in a variable

Author  Topic 

morphias0
Starting Member

20 Posts

Posted - 2006-02-22 : 13:55:59
for example i need a variables string to read: 'master','Test'
but the best i can do is get it to read: master, Test
heres what i have:

set @var = 'master, test'

I tried
set @var = ''master' + ',' + 'test''

but that doesnt work i get a invalid syntax error.... i know this is dumb but is it possible to do what i want?

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-02-22 : 13:59:40
Are you doing this so that you can use IN(@var)? If so:
http://www.sqlteam.com/item.asp?ItemID=11499

Otherwise:
set @var = '''master''' + ',' + '''test'''

Tara Kizer
aka tduggan
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-02-22 : 14:00:24
Set @var = char(39) + 'master' + char(39) + ',' + char(39) + 'Test' + char(39)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-23 : 01:57:22
or

set @var = '''master'',''test'''

But what are you trying to do with csv values?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-02-23 : 02:50:19
quote:
Originally posted by madhivanan

But what are you trying to do with csv values?





My guess is an IN list as tara suggested.



-ec
Go to Top of Page
   

- Advertisement -