SQL Server – Searching for Non-Alphanumeric characters Using Like
All I can say is I have never really needed to search for a percent sign or square brackets or a caret in a query until today. GooBling (Googling and Binging) didn’t return any useful results. Of course Kim Tripp, one of the sage SQL Server gurus always recommends checking Books Online first, shame on me for not checking there first but this wasn’t entirely obvious. Check out the details here: http://msdn.microsoft.com/en-us/library/ms179859.aspx
You can specify an escape character using a very, now, obvious escape character. An escape character placed in front of a pattern matching character will force SQL Server to recognize the pattern matching character as a normal character.
SELECT * FROM table WHERE col1 LIKE ‘%|%%’ ESCAPE ‘|’
The above query will return all rows where col1 contains a percent sign.