How to search underscore(_) in a column using sql server

SELECT * FROM TableName WHERE CHARINDEX('_' ,SomeColumn ) > 0
--Here all column will come which is having underscore

SELECT * FROM TableName WHERE SomeColumn LIKE '%/_%' ESCAPE '/'
-- you can give some pattern using like as well we have used escape sequence in this way

SELECT * FROM TableName WHERE SomeColumn LIKE '%[_]%' ESCAPE '/'
-- you can give some pattern using like

This is one of the best SQL Server Interview Question.

If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar