TFS 2018 WIQL查询LIKE条件报错:期望比较运算符,如何修正?
Ah, I ran into this exact snag when working with TFS 2018 a while back! The issue here is that WIQL (Work Item Query Language) in TFS 2018 doesn't support the standard SQL LIKE operator—it uses its own set of comparison operators for string and path matching.
The Correct Operators to Use
Depending on what you're trying to achieve, you'll want to use one of these WIQL-friendly operators:
1. Match Iteration Paths Containing Specific Text
If you just need to find work items where the IterationPath includes your target string ("MY ITERATION NAME"), use the Contains operator:
SELECT [System.Id], [System.WorkItemType], [System.Title], [System.State], [System.AreaPath], [System.IterationPath] FROM workitems WHERE [System.TeamProject] = @project AND [System.IterationPath] Contains 'MY ITERATION NAME' ORDER BY [System.IterationPath] ASC
2. Match a Parent Iteration and All Its Children
If your goal is to include work items from the target iteration and all its sub-iterations, use the Under operator instead. Just make sure to use the full path to your iteration:
SELECT [System.Id], [System.WorkItemType], [System.Title], [System.State], [System.AreaPath], [System.IterationPath] FROM workitems WHERE [System.TeamProject] = @project AND [System.IterationPath] Under 'YourProjectName\Iterations\MY ITERATION NAME' ORDER BY [System.IterationPath] ASC
Bonus: Other Useful WIQL String Operators
TFS 2018 WIQL also supports these for more precise matching:
Does Not Contain: Exclude items with the target textStarts With: Match paths that begin with your stringEnds With: Match paths that end with your string
内容的提问来源于stack exchange,提问作者TeoVr81

