Work Item Query Language (Work Item Query Reference)

A Work Item Query Language (WIQL) query consists of a SELECT statement that lists the fields to be returned as columns in the result set. You can further qualify the result set by using a logical expression. You can specify a sort order. Use an ASOF clause to state that a query is evaluated as of a previous time.

Queries are not case sensitive.

The following typical WIQL query example uses reference names for the fields. The query selects work items where the Priority field equals 1. The query returns the ID and Title of the return set as columns. The results are sorted by ID in ascending order.

SELECT System.ID, System.Title from workitems 
where Priority=1 order by System.ID asc

Examples

A query consists of a SELECT statement and a qualifying WHERE clause. The following shows the basic syntax.

SELECT

SELECT Select_List
   FROM workitems
   [WHERE Conditions]
   [ORDER BY Column_List]
   [ASOF DateTimeConditions]

The following example statements show specific qualifying clauses.

AND

SELECT [System.Id], [System.Title] 
   FROM WorkItems 
   WHERE [System.TeamProject] = @project 
   AND [System.AssignedTo] = 'Judy Lew'

OR

SELECT [System.Id], [System.Title] 
   FROM WorkItems 
   WHERE [System.TeamProject] = @project 
   AND ( [System.AssignedTo] = 'Mark Steele'
   OR [System.AssignedTo] = 'Merav Sror' )

NOT

SELECT [System.Id], [System.Title] 
   FROM WorkItems 
   WHERE [System.TeamProject] = @project 
   AND  [System.AssignedTo] EVER 'Anne Wallace'
   AND [System.AssignedTo] NOT CONTAINS 'Danny Levin'

EVER

SELECT [System.Id], [System.Title] 
   FROM WorkItems 
   WHERE [System.TeamProject] = @project 
   AND  [System.AssignedTo] EVER 'Anne Wallace'

UNDER

SELECT [System.Id], [System.Title] 
   FROM WorkItems 
   WHERE [System.TeamProject] = @project 
   AND [System.AssignedTo] EVER 'David Galvin'
   AND [System.AreaPath] UNDER 'Agile1\Area 0'

Sort

SELECT [System.Id], [System.Title] 
   FROM WorkItems 
   WHERE [System.TeamProject] = @project 
   AND [System.AssignedTo] = 'Jon Ganio'
   ORDER BY [System.Id] [asc | desc]

ASOF

SELECT [System.Title] 
   FROM workitems 
   WHERE [System.IterationPath] = 'MyProject\Beta' 
   AND [System.AssignedTo] = 'Jim Daly' 
   ASOF '3/16/06 12:30'

Community Additions

ADD
Show: