2b77bee6-5445-4c77-b1eb-4df3e5 2b77bee6-5445-4c77-b1eb-4df3e5 - 11 months ago 71
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