Escape Character in SQL Server

esquare picture esquare · Feb 28, 2011 · Viewed 418.8k times · Source

I want to use quotation with escape character. How can I do?

I have received error in SQL Server

Unclosed quotation mark after the character string.

I'm writing SQL query in a varchar variable but I have received that error:

Unclosed quotation mark after the character string.

I want to use quotation mark as an escape char.

Answer

dugokontov picture dugokontov · Feb 28, 2011

You can escape quotation like this:

select 'it''s escaped'

result will be

it's escaped