Skip to content

WIQL Guide

WIQL (Work Item Query Language) is SQL-like query language used by Azure DevOps to search and filter work items. adtk supports WIQL through both the CLI and MCP.

SELECT [Field1], [Field2]
FROM WorkItems
WHERE [Condition]
ORDER BY [Field] ASC|DESC
Terminal window
adtk search wiql "SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.State] = 'Active'"
Tool: manage_search
Input: {
"action": "wiql",
"query": "SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.State] = 'Active'",
"project_key": "MyProject"
}
WIQL FieldFlattened NameDescription
[System.Id]idWork item ID
[System.Title]titleTitle
[System.State]stateState (New, Active, Closed, etc.)
[System.WorkItemType]work_item_typeType (Bug, Task, User Story, etc.)
[System.AssignedTo]assigned_toAssigned user
[System.CreatedDate]created_dateCreation timestamp
[System.ChangedDate]changed_dateLast modified timestamp
[System.CreatedBy]created_byCreator
[System.AreaPath]area_pathArea path
[System.IterationPath]iteration_pathIteration/sprint path
[System.Tags]tagsTags
[Microsoft.VSTS.Common.Priority]priorityPriority (1-4)
[Microsoft.VSTS.Scheduling.StoryPoints]story_pointsStory points estimate
[Microsoft.VSTS.Common.StateChangeDate]state_change_dateWhen state last changed
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.State] = 'Active'
AND [System.AssignedTo] = @Me
ORDER BY [System.ChangedDate] DESC
SELECT [System.Id], [System.Title], [Microsoft.VSTS.Common.Priority]
FROM WorkItems
WHERE [System.WorkItemType] = 'Bug'
AND [System.State] <> 'Closed'
ORDER BY [Microsoft.VSTS.Common.Priority] ASC
SELECT [System.Id], [System.Title], [System.ChangedDate]
FROM WorkItems
WHERE [System.ChangedDate] >= @Today - 7
ORDER BY [System.ChangedDate] DESC
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.IterationPath] = @CurrentIteration
AND [System.WorkItemType] <> 'Task'
ORDER BY [Microsoft.VSTS.Common.Priority] ASC
SELECT [System.Id], [System.Title], [System.WorkItemType]
FROM WorkItems
WHERE [System.AssignedTo] = ''
AND [Microsoft.VSTS.Common.Priority] <= 2
AND [System.State] = 'New'
SELECT [System.Id], [System.Title]
FROM WorkItems
WHERE [System.Tags] CONTAINS 'frontend'
AND [System.State] <> 'Closed'
SELECT [System.Id], [System.Title], [System.WorkItemType]
FROM WorkItemLinks
WHERE [Source].[System.WorkItemType] = 'User Story'
AND [Target].[System.WorkItemType] = 'Task'
AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'
MODE (Recursive)
SELECT [System.Id], [System.Title], [System.CreatedDate]
FROM WorkItems
WHERE [System.CreatedBy] = 'Jane Doe'
AND [System.CreatedDate] >= @Today - 30
ORDER BY [System.CreatedDate] DESC
SELECT [System.Id], [System.Title], [System.State]
FROM WorkItems
WHERE [System.AreaPath] UNDER 'MyProject\Backend'
ORDER BY [System.Id] ASC
OperatorDescriptionExample
=Equals[System.State] = 'Active'
<>Not equals[System.State] <> 'Closed'
>, <, >=, <=Comparison[Microsoft.VSTS.Common.Priority] <= 2
CONTAINSContains substring[System.Tags] CONTAINS 'api'
NOT CONTAINSDoes not contain[System.Title] NOT CONTAINS 'test'
INIn a set[System.State] IN ('Active', 'New')
NOT INNot in a set[System.WorkItemType] NOT IN ('Task', 'Test Case')
UNDERUnder a path (hierarchical)[System.AreaPath] UNDER 'Project\Team'
=''Is empty[System.AssignedTo] = ''
<>''Is not empty[System.AssignedTo] <> ''
MacroDescription
@MeCurrent authenticated user
@TodayToday’s date (can do arithmetic: @Today - 7)
@CurrentIterationThe current sprint/iteration
@ProjectCurrent project context

adtk uses the WIQL 2-step pattern:

  1. Execute the query — POST the WIQL to the ADO API, which returns a list of work item IDs
  2. Batch fetch — GET the full work items by ID in batches of up to 200

This is more efficient than fetching full work items inline, especially for large result sets.

Terminal window
# Limit results with the --top flag
adtk search wiql "SELECT [System.Id] FROM WorkItems WHERE [System.State] = 'Active'" --top 10