Sql Escape Single Quote

Last Updated On Monday 6th Dec 2021

sql server escape single quote

	DECLARE @text as NVARCHAR(400)
SET @text = 'I'm Still Studying.'
SELECT @text
	

The above code gives error Incorrect syntax near 'm'

Escaping the quote

Put an extra quote in front of that word. Now is recognized the whole thing as a text value like below.

sql escape single quote

	DECLARE @text as NVARCHAR(400)
SET @text = 'I''m Still Studying.'
SELECT @text
	
	I'm Still Studying.
	
  • The doubling up of the quote should have worked.