Technical Article

Replacing Single Quotes

,

The script shows you a quick way to replace single quotes - or any special character for that matter - from text or text columns using SQL.

For reference information about Character Codes, look up ASCII character codes.

declare @var nvarchar(40)
set @var = 'Don' + REPLICATE(char(39),2) + 't quote me on this!'
select
 @var as [in]
, REPLACE(@var, char(39), '') as [out]
Go

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating