2

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?

Phillip Scott Givens
  • 5,256
  • 4
  • 32
  • 54

1 Answers1

3

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

Elmar
  • 1,236
  • 1
  • 11
  • 16
  • Both of these were very helpful. I thought I had tried the first, but the second was a great verifier! Thanks! – Phillip Scott Givens Mar 01 '16 at 20:39
  • Pleasure, I thought you'd like the second one since you're likely going to be writing some additional queries against the api in future too, just makes it way quicker to get the queries done and dusted :) – Elmar Mar 01 '16 at 20:42