How can i get the records that contain a single quotation mark in SQL Server?
The following as you guess, is not valid, but you get the point
SELECT [Id], [Name] FROM [People] WHERE Name LIKE '%'%'
How can i get the records that contain a single quotation mark in SQL Server?
The following as you guess, is not valid, but you get the point
SELECT [Id], [Name] FROM [People] WHERE Name LIKE '%'%'
 
    
    The double single quote is interpreted as a single quote in a string:
SELECT [Id], [Name] FROM [People] WHERE Name LIKE '%''%'
 
    
    You need to escape the quote
SELECT [Id], [Name] FROM [People] WHERE Name LIKE '%''%'
 
    
    In your query, the % are under 3 ' (like '%'%'). They should be under 4.
SELECT [Id], [Name] FROM [People] WHERE Name LIKE '%''%'
The % are now escaped in this query.
 
    
    You can do the escape code as others have mentioned or you can use the char code 39, where CHAR(39) is '.
SELECT [Id], [Name] FROM [People] WHERE Name LIKE '%' + CHAR(39) + '%'
