1

I want to search and select columns where there is a single quote (') present in the text using LIKE or CONTAINS Predicate.

consider the following text : 10011-RIO MARE EXTRA'

0

4 Answers 4

3
CREATE TABLE #TEST ( Test_Column VARCHAR(MAX)); INSERT INTO #TEST VALUES ('10011-RIO MARE EXTRA''') SELECT * FROM #TEST WHERE Test_Column LIKE '%''%' 

The escape character for ' is ' used twice -> ''.

Sign up to request clarification or add additional context in comments.

Comments

1

try this

select * from yourtable where youcolumn like '%''%' 

1 Comment

Can you please tell me how this actually works.
1

Find records with single quotes in the table

SELECT * FROM [tableName] where Name like '%''%' 

Comments

-1

I hope this solves your problem

% ' % -> Finds any values that have " ' " in any position

By executing below query you will get the result which have '(single quote) in them

SELECT * FROM TABLE_NAME WHERE COLUMN_NAME LIKE "%'%" 

i have executed the same query enter image description here

8 Comments

I am getting an error when I run your query in SQL server.
Error : Msg 207, Level 16, State 1, Line 6 Invalid column name '%'%'.
in your query try using "%'%" instead of '%'%' you are using single quote i guess may be that is the problem
this is just wrong, double quotes cannot be used in sql server
@ShardulSinghGurjar as you have mentioned you use adminer, i suspect you are using mysql and not sql server
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.