开发者

Using Like T SQL Statement to search and replace quotation marks

开发者 https://www.devze.com 2023-01-23 10:06 出处:网络
Because the quotation mar开发者_开发知识库k is a special character is there a way to replace all quotation with nothing

Because the quotation mar开发者_开发知识库k is a special character is there a way to replace all quotation with nothing

Original Query

Update table X
Set mycolumn = Replace(mycolumn,''','')
Where mycolumn like '%'%'

Error

(Incorrect SQL Syntax - Unclosed quotation mark after the character string ''')


You need to escape the ' by doubling it:

Update table X
Set mycolumn = Replace(mycolumn,'''','')
Where mycolumn like '%''%'

Though the Where clause is probably redundant.


Escape the single quote ' by doubling ''

Update table X 
Set mycolumn = Replace(mycolumn,'''','') 

you don't need the superfluous WHERE clause.


Hmm - not entirely sure what you are up to, but you could try the QuoteName string function.

0

精彩评论

暂无评论...
验证码 换一张
取 消