Use wildcard characters in conditions for string values
You can use wildcard characters when you construct queries using conditions on string values with the following operators:
like
not-like
begins-with
not-begin-with
ends-with
not-end-with
More information: Use FetchXML to construct a query
When using these condition operators you can use certain characters to represent wildcards in your search criteria.
These characters are described in the following table:
| Characters | Description | T-SQL Documentation and examples |
|---|---|---|
% |
Matches any string of zero or more characters. This wildcard character can be used as either a prefix or a suffix. | Percent character (Wildcard - Character(s) to Match) (Transact-SQL) |
_ |
Use the underscore character to match any single character in a string comparison operation that involves pattern matching. | _ (Wildcard - Match One Character) (Transact-SQL) |
[] |
Matches any single character within the specified range or set that is specified between brackets. | [ ] (Wildcard - Character(s) to Match) (Transact-SQL) |
[^] |
Matches any single character that is not within the range or set specified between the square brackets. | [^] (Wildcard - Character(s) Not to Match) (Transact-SQL) |
Search for strings that contain wildcard characters
You can use the wildcard pattern matching characters as literal characters. To use a wildcard character as a literal character, enclose the wildcard character in brackets. More information: Using Wildcard Characters As Literals.
Do not use trailing wild cards
Using trailing wildcards is not supported.
Important
Do not use trailing wild cards in expressions using begins-with, not-begin-with, ends-with or not-end-with. The following table gives some examples of trailing wildcards:
| Bad Examples |
|---|
<condition attribute='name' operator='begins-with' value='%value' /> |
<condition attribute='name' operator='not-begins-with' value='%value' /> |
<condition attribute='name' operator='ends-with' value='value%' /> |
<condition attribute='name' operator='not-ends-with' value='value%' /> |
Queries using these anti-patterns introduce performance problems because the queries cannot be optimized.
See also
Use FetchXML to construct a query
Use the ConditionExpression class
Query data using the Web API
Зворотний зв’язок
Надіслати й переглянути відгук про