SQL Question

SQL literal escape character

What is the escape character for MS-SQL-Server

WHERE field1 LIKE 'I'm'

Note the middle quotation is invalid, what is SQL's literal character, like / in C#

Answer Source

Use double ' to escape it in SQL-Server

WHERE field1 LIKE 'I''m'

In other DB engines like MySQL using backslash works too

WHERE field1 LIKE 'I\'m'

SQLFiddle demo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download