开发者

Using Like T SQL Statement to search and replace quotation marks

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜