The Like clause in SQL Server uses the following wildcard characters:
Percent (%)
Underscore (_)
Square Brackets ([])
Caret (^)
Most of us know about % and _ but what about the remaining wildcard characters so let us see them in details.
Square Brackets [] are used to replace any one char within a set or range of characters.
Let see this Example for a set of characters:
So the result set will return any product name start by a,b or c.
Now let see example for
range of characters:
So the result set will return any product name start by a,b,c or d.
Caret (^) is working as square bracket but in reverse way so [^a-c] means include all characters except the a,b or c.
Let see this example :
So the result set will return all producat name does not start by a,b,c or d.
Written by Fadi Ahmad Abdulwahab