Srinivas
Srinivas

Reputation: 2100

Searching for strings with double quotes in SQL Server

I want to find out all rows that have a double quotes character in a particular field.

I am trying something like charindex(columnname,'""') in the where clause, but it does not seem to work.

Any help will be much appreciated.

Upvotes: 9

Views: 36464

Answers (3)

Lam
Lam

Reputation: 436

Try

select * from db where name  like '%\"%'

Upvotes: 0

Chris J
Chris J

Reputation: 936

If there is only one double quote then you should try

select * from tablename where columnname like '%"%'

If you know that there are two consecutive double quotes then, I would suggest you to use a like statement

select * from tablename where columnname like '%""%'

Otherwise if you don't know then you should try(Which is more preferable)

select * from tablename where columnname like '%"%"%'

Upvotes: 8

taotechnocom
taotechnocom

Reputation: 228

Try this.

SELECT * FROM tb WHERE col Like '%"%'

Or

SELECT * FROM tb WHERE CHARINDEX('"',col) > 0

Upvotes: 3

Related Questions