Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi allHow to enter single quote character in a sting column for eg: Channel'sThanks
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2006-09-22 : 02:04:55
escape it with another single quote
'Channel''s'
KH
venkath
Posting Yak Master
202 Posts
Posted - 2006-09-22 : 02:07:11
Thanks
ditch
Master Smack Fu Yak Hacker
1466 Posts
Posted - 2006-09-22 : 05:59:54
Another option is to use the ascii code for the single quote ie 39.select 'Channel' + CHAR(39) + 's'Duane.
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2006-09-23 : 09:06:47
To know the behaviour of single quotes, run thisSelect '','''','''''','''''''',''''''''''MadhivananFailing to plan is Planning to fail
Kristen
Test
22859 Posts
Posted - 2006-09-23 : 12:41:56
Evil!Then there is this:
DECLARE @strSQL varchar(8000)SELECT @strSQL = 'SELECT TOP 10 name FROM master.dbo.sysobjects WHERE type = ''U''' SELECT @strSQL = 'SELECT *FROM OPENQUERY(MyServer, ''' + REPLACE(@strSQL, '''', '''''') + ''')'PRINT @strSQLEXEC (@strSQL)
Kristen
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2006-09-24 : 20:47:22
Well. General rule may be Between first and last single quotes, every double single quotes is converted to single single quoteMadhivananFailing to plan is Planning to fail