A description of the search for wildcard-wildcard
You can search for wildcard characters. There are two ways to specify characters that are commonly used as wildcards:
Use the Escape keyword to define an escape character. In a pattern, the wildcard is interpreted as a normal character when the escape character is placed before a wildcard. For example, to search for a string containing the string 5% anywhere, use:
WHERE ColumnA like '%5/%% ' ESCAPE '/'
In the LIKE clause above, the leading and trailing percent sign (%) is interpreted as a wildcard character, and the percent semicolon after the slash (/) is interpreted as% of characters.
Only the wildcard character itself is included in the square brackets ([]). To search for a dash (-) instead of specifying a search scope, specify the dash as the first character in square brackets:
WHERE ColumnA like ' 9[-]5 '
The following table shows the use of wildcard characters enclosed in square brackets.
symbols |
meaning |
Like ' 5[%] ' |
5% |
Like ' 5% ' |
5 string followed by 0 or more characters |
Like ' [_]n ' |
_n |
Like ' _n ' |
An, in, on (and) |
Like ' [A-CDF] ' |
A, B, C, D, or F |
Like ' [-ACDF] ' |
-, A, C, D, or F |
Like ' [[] ' |
[ |
Like '] ' |
] |
Second, the example description:
Look in the table Personalmember to find records in the Strloginname field that contain "[".
You can use three statements:
1,
Select strloginname,* from Personalmember where strloginname like '%\[% ' escape '
2. (description "\" and "/" can be combined with escape keyword as escape character)
Select strloginname,* from Personalmember where strloginname like '%/[% ' escape '/'
3,
Select strloginname,* from dbo. Personalmember where CHARINDEX (' [', Strloginname) >0