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
 Transact-SQL (2000)
 special character

Author  Topic 

1fred
Posting Yak Master

158 Posts

Posted - 2003-03-24 : 12:06:49
How can I just make this simple select to return me the ' character. Is there an escaping character in sql? When I type :

select '

nic
Posting Yak Master

209 Posts

Posted - 2003-03-24 : 12:14:04
to return just single ' do this: (it is 2 quotes but it is also inclosed in quotes)
select ''''

If you are building dynamic sql and want to put quotes around a field it would be something like this
@sql = 'Select field from table where field = ''test'''



Nic
Go to Top of Page

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2003-03-24 : 12:24:18
I second the suggestion from nic, but to provide readability, I prefer something like so:

@sql = 'Select field from table where field = ' + CHAR(39) + 'test' + CHAR(39)

Go to Top of Page
   

- Advertisement -