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.
精彩评论