Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,


How to retrieve records from the database using like operator if the records present in the table contains single quotes and double quotes.I need a single query.









Thanks
Posted

Try This

SQL
SELECT * FROM dbo.Table WHERE Text LIKE '%''%' AND Text LIKE '%"%'


Regards

AB Abulubbad
 
Share this answer
 
v2
Try this.
SQL
SELECT * FROM tablename WHERE column_name LIKE '%''%' OR column_name LIKE '%"%'
 
Share this answer
 
v2
Comments
imaa2amha 14-Sep-11 5:11am    
is my solution wrong :P
Toniyo Jackson 14-Sep-11 5:14am    
You should use OR operator. He need both single & double quotes.
imaa2amha 14-Sep-11 6:57am    
he said quotes and double quotes not Or Double quotes
Toniyo Jackson 14-Sep-11 7:00am    
AND will work if both condition satisfy. Do you know that?
You need to use ESCAPE
SQL
WHERE c1 LIKE '%10-15!% off%' ESCAPE '!'


http://msdn.microsoft.com/en-us/library/ms179859.aspx[^]
 
Share this answer
 
Try this

SQL
select * from (select 'Zebronic''s' a) t where a like '%' + char(39) + '%'


char(39) = '
char(34) = "
 
Share this answer
 
Comments
3796068 14-Sep-11 5:09am    
Thanks everybody.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900