Here is a quick tip, when you are searching for a text that contains square brackets “[]” in Microsoft SQL Server. For example you are searching for a text that contains “text text text [text] text text”. A simple query using LIKE % would not do the trick.
One has to add double square brackets to search for the square bracket text.
Example
1 |
Select * from Employee where Status like '[Part-Time]' |
The previous query will not return any match items. But if you replace the query with double brackets like
1 2 3 4 |
Select * from Employee where Status like '[[Part-Time]' or Select * from Employee where Status like '[[]Part-Time]' |
The above will return you data that match the square bracket text.
Leave A Comment