Ads by ProfitSence
Close

Sql Escape Single Quote

Last Updated on Wednesday 5th Oct 2022

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.