![]() | ![]() |
Home |
|
|
Transact-SQL User's Guide |
|
| Chapter 2 Queries: Selecting Data from a Table |
|
| Pattern matching |
|
| Matching character strings: like |
|
| Using wildcard characters as literal characters |
|
| Square brackets (Transact-SQL extension) |
Use square brackets for the percent sign, the underscore, and right and left brackets. To search for a dash, rather than using it to specify a range, use the dash as the first character inside a set of brackets.
like clause | Searches for |
like "5%" | 5 followed by any string of 0 or more characters |
like "5[%]" | 5% |
like "_n" | an, in, on, and so forth |
like "[_]n" | _n |
like "[a-cdf]" | a, b, c, d, or f |
like "[-acdf]" | -, a, c, d, or f |
like "[ [ ]" | [ |
like "[ ] ]" | ] |
|
|