Search code examples
tfswiql

TFS WIQL Query with like condition


I need to write a WIQL query on TFS 2018 with a like condition in the field IterationPath like this:

SELECT
        [System.Id],
        [System.WorkItemType],
        [System.Title],
        [System.State],
        [System.AreaPath],
        [System.IterationPath]
FROM workitems
WHERE
        [System.TeamProject] = @project
        and [System.IterationPath] LIKE '%MY ITERATION NAME%' 
ORDER BY [System.IterationPath] ASC

but I receive the error:

Expecting comparison operator. The error is caused by «LIKE».

How I have to write the query?


Solution

  • The valid operators for Iteration Path are:

    enter image description here

    So you can't use Like (there is no Like operator in WIQL at all) or Contains.

    The closest valid operator is Under, if all the iterations are under one parent you will get them all.

    More info you can find here.