How to insert text with single quotation sql server 2005

ramesh picture ramesh · Apr 22, 2009 · Viewed 165.3k times · Source

I want to insert text with single quote Eg john's to table in sql server 2005 database

Answer

Binoj Antony picture Binoj Antony · Apr 22, 2009

Escape single quote with an additional single as Kirtan pointed out
And if you are trying to execute a dynamic sql (which is not a good idea in the first place) via sp_executesql then the below code would work for you

sp_executesql N'INSERT INTO SomeTable (SomeColumn) VALUES (''John''''s'')'