This weeks tip:
I use wildcards and the “LIKE” operator in my TSQL all the time – a lot of the time to find table names, column names etc.
Select OBJECT_NAME (OBJECT_ID), NAME from sys.columns where name like '%file%'
Ninety eight percent of the time, I use the %. The other two percent, I need to look up the exact syntax. Well, here’s a quick reference for you:
| Wild Card | Description |
| % | Any string of characters i.e. %ID% |
| _ | Any single character i.e. _ndy |
| [] | Any single single character in a range specified or set i.e. [A-L] OR [ABC] |
| [^] | Any single single character not in a range specified or set i.e. [^A-L] OR [^ABC] |
Sometimes an issue comes up where you need to search for the actual wildcard character, for more info on that, check out the section titled “Using Wildcard Characters As Literals” from the MSD article on LIKE.
Here are some related posts from the intraweb:
- A good article from devasp.net here: SQL Server 2005 and WildCards characters note – it’s 2005, but it still applies.
- A good few good examples from SQL Tutorial here: SQL Like


