Sunday, November 4, 2018

SQL Server - How to Replace single quotes


Use Replace function with double the no of quotes.


select top 1 Field_Name from [mytable]


Field'sWithSingleQuote

Now 

select top 1 replace (Field_Name,'''','') from [mytable]

or using ASCII Code of  '


select top 1 replace (Field_Name,char(39),'') from [mytable]

FieldsWithSingleQuote

No comments:

Post a Comment

Recently Executed queries

 SELECT     txt.TEXT AS [SQL Statement],     qs.EXECUTION_COUNT [No. Times Executed],     qs.LAST_EXECUTION_TIME AS [Last Time Executed],   ...