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.
Author |
Topic |
suchiate
Starting Member
33 Posts |
Posted - 2006-12-11 : 23:41:19
|
Hi guys,I am working on a stored procedure which requires appending a single quote to a variable string, but SQL treats strings enclosed in single quotes. Can anyone teach me how to represent single quote to allow my procedure to insert single quotes?I have tried the below:1. SET @var = '''2. SET @var = "'"3. SET @var = convert(varchar,"'")obviously 1 will not work, and 2 and 3 returns invalid column name '''.Please help me out, thanks guys. |
|
gsgill76
Posting Yak Master
137 Posts |
Posted - 2006-12-12 : 00:04:34
|
Try thisDECLARE @var varchar(10)SET @var = 'GILL'''PRINT @var Rule of thumb is put TWO single quotes, if u need to put single quote in the string.More Information: ReadSET QUOTED_IDENTIFIER (Transact-SQL) from BOL.Gurpreet S. Gill |
|
|
suchiate
Starting Member
33 Posts |
Posted - 2006-12-12 : 00:14:36
|
Thank you so much Gill :) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-12 : 05:59:20
|
You need to double the single quote. Run this to know how it behavsSelect '','''','''''','''''''',''''''''''MadhivananFailing to plan is Planning to fail |
|
|
|
|
|