TSQL Query: Escaping Special Characters

Posted by Abs on Stack Overflow See other posts from Stack Overflow or by Abs
Published on 2010-04-22T11:45:00Z Indexed on 2010/04/22 11:53 UTC
Read the original article Hit count: 546

Filed under:
|

Hello all,

I am trying to escape special characters in a TSQL query. I have done this before:

SELECT columns FROM table WHERE column LIKE '%\%%' ESCAPE '\'

And it has worked. Now I have tried to do this now:

UPDATE match SET rule_name='31' ESCAPE '\'

But it has failed. I know none of the vlaues have a \ but it should still work. I am guessing its because it needs a LIKE statement but how else can I escape characters that I am adding to a database?

In addition, does anyone have a link to all the special characters that should be escaped, I couldn't find any documentation on this!

Thanks all for any help

© Stack Overflow or respective owner

Related posts about tsql

Related posts about sql-server