Use wildcard characters in conditions for string values
You can use wildcard characters with the following operators when you build queries that include conditions on string values:
like
not-like
begins-with
not-begin-with
ends-with
not-end-with
More information: Query data using FetchXml
When you use these condition operators, you can use certain characters to represent wildcards in your search criteria. The following table describes the characters you can use.
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) |
_ |
Matches any single character in a string comparison operation that involves pattern matching. | _ (Wildcard - Match One Character) (Transact-SQL) |
[] |
Matches any single character in the range or set that's specified between square brackets. | [ ] (Wildcard - Character(s) to Match) (Transact-SQL) |
[^] |
Matches any single character that isn't in the range or set that's 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.
Don't use trailing wild cards
Using trailing wildcards isn't supported.
Don't use trailing wild cards in expressions using begins-with
, not-begin-with
, ends-with
, or not-end-with
.
Here are 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 that use these anti-patterns introduce performance problems because the queries can't be optimized.
See also
Query data using FetchXml
Use the ConditionExpression class
Query data using the Web API
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기