Search code examples
tfswiql

TFS WIQL does not support 'Does Not Contain'. Is there an alternative?


Here is something that I can do from Visual Studio, but cannot seem to do through the TFS API using WIQL.

SELECT * 
FROM WorkItems
WHERE WorkItemType = Bug
AND Tags CONTAINS 'MyTag'
AND Tags DOES NOT CONTAIN 'OtherTag'

How do I query with a 'DOES NOT CONTAIN' filter?


Solution

  • Well I have two things for you to try...

    Firstly try this query:

    SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags] 
    FROM WorkItems 
    WHERE [System.TeamProject] = @project  
    AND  [System.WorkItemType] = 'Bug'  
    AND  [System.Tags] CONTAINS 'MyTag'  
    AND  [System.Tags] NOT CONTAINS 'OtherTag' 
    ORDER BY [System.Id]
    

    and secondly, do this...

    View the query you have saved in tfs via visual studio, drag the query from the query explorer window onto your desktop. open the file that is created on your desktop with notepad and check the contents. it will contain your WIQL.

    enter image description here