Endpoint Query Work Items
Name
query_workitems
Description
Get work items associated with the specified project and organization that are filtered by a Wiql query. (A team can optionally be specified as well.). Read more about this API here https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/wiql/query-by-wiql?view=azure-devops-rest-7.0 and here https://learn.microsoft.com/en-us/azure/devops/boards/queries/query-operators-variables?view=azure-devops [API reference]
Related Tables
Parameters
| Parameter | Required | Options | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Name:
Label: Project Name The Name of the project. |
YES | |||||||||||||
|
Name:
Label: Wiql Query The WIQL query (refer Azure DevOps Help to learn Wiql syntax. |
YES | |||||||||||||
|
Name:
Label: Team Id or Name Id or name of the team associated with the query. |
||||||||||||||
|
Name:
Label: Use time precision Whether or not to use time precision. |
|
|||||||||||||
|
Name:
Label: Expand Parameters (Set Blank for fast response) The expand parameters for work item attributes. Possible options are 'None', 'Relations', 'Fields', 'Links', and 'All'. Set 'Relations' if you need ParentId field. |
|
Output Columns
| Label | Data Type (SSIS) | Data Type (SQL) | Length | Description |
|---|---|---|---|---|
| Id |
DT_I4
|
int
|
||
| Title |
DT_WSTR
|
nvarchar(1000)
|
1000 | |
| Description |
DT_NTEXT
|
nvarchar(MAX)
|
||
| WorkItemType |
DT_WSTR
|
nvarchar(100)
|
100 | |
| State |
DT_WSTR
|
nvarchar(100)
|
100 | |
| Url |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| Tags |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| Revision |
DT_I4
|
int
|
||
| AreaPath |
DT_WSTR
|
nvarchar(500)
|
500 | |
| TeamProject |
DT_WSTR
|
nvarchar(500)
|
500 | |
| IterationPath |
DT_WSTR
|
nvarchar(500)
|
500 | |
| Reason |
DT_WSTR
|
nvarchar(500)
|
500 | |
| CreatedDate |
DT_DBTIMESTAMP
|
datetime
|
||
| ChangedDate |
DT_DBTIMESTAMP
|
datetime
|
||
| CommentCount |
DT_I4
|
int
|
||
| ParentId |
DT_I4
|
int
|
Only returned if Expand Parameter is set to Relations or All | |
| AssignedToDisplayName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| AssignedToUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| AssignedToLinksAvatarHref |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| AssignedToId |
DT_WSTR
|
nvarchar(500)
|
500 | |
| AssignedToUniqueName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| AssignedToImageUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| AssignedToDescriptor |
DT_WSTR
|
nvarchar(2000)
|
2000 | |
| CreatedByDisplayName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| CreatedByUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| CreatedByLinksAvatarHref |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| CreatedById |
DT_WSTR
|
nvarchar(500)
|
500 | |
| CreatedByUniqueName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| CreatedByImageUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| CreatedByDescriptor |
DT_WSTR
|
nvarchar(2000)
|
2000 | |
| ChangedByDisplayName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ChangedByUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ChangedByLinksAvatarHref |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ChangedById |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ChangedByUniqueName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ChangedByImageUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ChangedByDescriptor |
DT_WSTR
|
nvarchar(2000)
|
2000 | |
| Watermark |
DT_WSTR
|
nvarchar(500)
|
500 | |
| StateChangeDate |
DT_DBTIMESTAMP
|
datetime
|
||
| Priority |
DT_I4
|
int
|
||
| Triage |
DT_WSTR
|
nvarchar(1000)
|
1000 | |
| StackRank |
DT_I4
|
int
|
||
| Blocked |
DT_WSTR
|
nvarchar(500)
|
500 | |
| TaskType |
DT_WSTR
|
nvarchar(500)
|
500 | |
| RequiresReview |
DT_WSTR
|
nvarchar(100)
|
100 | |
| RequiresTest |
DT_WSTR
|
nvarchar(100)
|
100 | |
| ActivatedDate |
DT_DBTIMESTAMP
|
datetime
|
||
| ActivatedByDisplayName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ActivatedByUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ActivatedByLinksAvatarHref |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ActivatedById |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ActivatedByUniqueName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ActivatedByImageUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ActivatedByDescriptor |
DT_WSTR
|
nvarchar(2000)
|
2000 | |
| ClosedDate |
DT_DBTIMESTAMP
|
datetime
|
||
| ClosedByDisplayName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ClosedByUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ClosedByLinksAvatarHref |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ClosedById |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ClosedByUniqueName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ClosedByImageUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ClosedByDescriptor |
DT_WSTR
|
nvarchar(2000)
|
2000 | |
| ResolvedDate |
DT_DBTIMESTAMP
|
datetime
|
||
| ResolvedByDisplayName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ResolvedByUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ResolvedByLinksAvatarHref |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ResolvedById |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ResolvedByUniqueName |
DT_WSTR
|
nvarchar(500)
|
500 | |
| ResolvedByImageUrl |
DT_WSTR
|
nvarchar(2048)
|
2048 | |
| ResolvedByDescriptor |
DT_WSTR
|
nvarchar(2000)
|
2000 | |
| ResolvedReason |
DT_WSTR
|
nvarchar(4000)
|
4000 | |
| AreaId |
DT_WSTR
|
nvarchar(500)
|
500 | |
| IterationId |
DT_WSTR
|
nvarchar(500)
|
500 | |
| RevisedDate |
DT_DBTIMESTAMP
|
datetime
|
||
| RemoteLinkCount |
DT_I4
|
int
|
||
| RelatedLinkCount |
DT_I4
|
int
|
||
| HyperLinkCount |
DT_I4
|
int
|
||
| ExternalLinkCount |
DT_I4
|
int
|
||
| History |
DT_NTEXT
|
nvarchar(MAX)
|
||
| IntegrationBuild |
DT_WSTR
|
nvarchar(500)
|
500 | |
| FoundIn |
DT_WSTR
|
nvarchar(500)
|
500 | |
| OriginalEstimate |
DT_R4
|
real
|
||
| RemainingWork |
DT_R4
|
real
|
||
| CompletedWork |
DT_R4
|
real
|
||
| Size |
DT_R4
|
real
|
||
| Effort |
DT_R4
|
real
|
||
| TargetDate |
DT_DBTIMESTAMP
|
datetime
|
||
| StoryPoints |
DT_R4
|
real
|
||
| StartDate |
DT_DBTIMESTAMP
|
datetime
|
||
| FinishDate |
DT_DBTIMESTAMP
|
datetime
|
||
| DueDate |
DT_DBTIMESTAMP
|
datetime
|
||
| Discipline |
DT_WSTR
|
nvarchar(500)
|
500 | |
| SystemInfo |
DT_NTEXT
|
nvarchar(MAX)
|
||
| Steps |
DT_NTEXT
|
nvarchar(MAX)
|
||
| ReproSteps |
DT_NTEXT
|
nvarchar(MAX)
|
||
| Severity |
DT_WSTR
|
nvarchar(100)
|
100 | |
| ProposedFix |
DT_NTEXT
|
nvarchar(MAX)
|
||
| Symptom |
DT_NTEXT
|
nvarchar(MAX)
|
||
| RootCause |
DT_WSTR
|
nvarchar(100)
|
100 | |
| HowFound |
DT_WSTR
|
nvarchar(100)
|
100 | |
| FoundInEnvironment |
DT_WSTR
|
nvarchar(100)
|
100 | |
| BusinessValue |
DT_I4
|
int
|
||
| ValueArea |
DT_WSTR
|
nvarchar(100)
|
100 | |
| TestedBy |
DT_WSTR
|
nvarchar(500)
|
500 | |
| TestPriority |
DT_I4
|
int
|
||
| Activity |
DT_WSTR
|
nvarchar(100)
|
100 | |
| [$parent.referenceName$] |
DT_WSTR
|
nvarchar(4000)
|
4000 |
Input Columns
| Label | Data Type (SSIS) | Data Type (SQL) | Length | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Examples
SSIS
Use Azure DevOps Connector in API Source or in API Destination SSIS Data Flow components to read or write data.
API Source
This Endpoint belongs to the WorkItems table, therefore it is better to use it, instead of accessing the endpoint directly:
| Required Parameters | |
|---|---|
| Project Name | Fill-in the parameter... |
| Wiql Query | Fill-in the parameter... |
| Optional Parameters | |
| Team Id or Name | |
| Use time precision | |
| Expand Parameters (Set Blank for fast response) | Relations |
API Destination
This Endpoint belongs to the WorkItems table, therefore it is better to use it, instead of accessing the endpoint directly. Use this table and table-operation pair to query work items:
| Required Parameters | |
|---|---|
| Project Name | Fill-in the parameter... |
| Wiql Query | Fill-in the parameter... |
| Optional Parameters | |
| Team Id or Name | |
| Use time precision | |
| Expand Parameters (Set Blank for fast response) | Relations |
ODBC application
Use these SQL queries in your ODBC application data source:
List work items (default project)
<p>Returns work items from the default project specified in the connection (or the project you set in the WITH clause). Use this as the baseline list; you can filter by ID, state, or other columns in the WHERE clause, or pass a WIQL query in WITH to filter on the server.</p>
SELECT * FROM WorkItems
List work items for a project
<p>Lists work items for a specific project by supplying the project name in the WITH clause. Use this when your connection default is one project but you need to query another. You can combine with a WHERE clause or a WIQL query in WITH to narrow results.</p>
SELECT * FROM WorkItems WITH (Project='ProductTesting')
List work items with ParentId
<p>By default, relation fields such as ParentId are not returned so that list queries stay fast. When you need parent-child or other link information, set <code>Expand='Relations'</code> in the WITH clause. The result set will then include ParentId and other relation columns so you can join or filter by hierarchy.</p>
SELECT * FROM WorkItems WITH(Expand='Relations')
Query work items by WIQL (filters and date range)
<p>Use a WIQL (Work Item Query Language) query to filter work items by project, ID range, changed/created dates, work item type, state, priority, and more. The query runs on the server and returns only matching rows. This example shows typical filters: project, ID range, date variables like @Today and @StartOfYear, and ordering by changed date.</p><p>For full syntax and operators, see <a href="https://learn.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops">WIQL syntax</a> and <a href="https://learn.microsoft.com/en-us/azure/devops/boards/queries/query-operators-variables?view=azure-devops">query operators and variables</a>.</p>
SELECT * FROM WorkItems WITH (Query='SELECT * FROM WorkItems
WHERE [System.Id] > 2000 AND [System.Id] < 7050
AND [System.TeamProject]=''ProductTesting''
AND [System.ChangedDate] < @Today
AND [System.CreatedDate] > @StartOfYear
AND [System.WorkItemType]=''Task''
AND [System.State]=''Resolved''
AND [Microsoft.VSTS.Common.Priority] >= 1
ORDER BY [System.ChangedDate] DESC
')
Query work items modified after a date (dynamic)
<p>Use placeholder functions (e.g. monthstart, today, yearend) and arithmetic (e.g. monthstart-1d) to build dynamic dates in your WIQL query so the same statement always reflects the intended period without manual date changes. The placeholder is evaluated before the query is sent to Azure DevOps.</p><p>For placeholder syntax and options see <a href="https://zappysys.com/links/?id=10014">placeholder functions</a>. For WIQL see <a href="https://learn.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops">WIQL syntax</a>.</p>
SELECT * FROM WorkItems WITH (Query='SELECT * FROM WorkItems
WHERE [System.TeamProject]=''ProductTesting''
AND [System.ChangedDate] >= ''<<monthstart-1d,FUN_TO_DATE>>''
ORDER BY [System.ChangedDate] DESC
')
Query work items by WIQL in a project
<p>Runs a WIQL query in a specific project by passing both the project name and the query in the WITH clause. Use this when the connection default is different from the project you want to query, or when you need to target one project explicitly. The query can filter by ID, state, type, or any other WIQL criteria.</p>
SELECT * FROM WorkItems WITH (Project='PosProject', Query='SELECT * FROM WorkItems WHERE [System.Id] = 2819')
Query work items by type (e.g. Task)
<p>Returns work items of a given type (e.g. Task, Bug, User Story) by filtering with a WIQL query on <code>System.WorkItemType</code>. Use this to list all tasks, all bugs, or any other type. You can combine with other WIQL conditions (state, project, dates) in the same query string.</p>
SELECT * FROM WorkItems WITH (Query='SELECT * FROM WorkItems WHERE [System.WorkItemType] = ''Task''')
Query work items using WIQL
<p>Run a WIQL query to filter work items by project and criteria; the query is passed in the WITH clause and executed on the server. You can select specific columns (e.g. Id, Title, Description, CreatedDate, Url) or use * to return all columns. WIQL supports project, ID, state, work item type, dates, and more.</p><p>For syntax and operators see <a href="https://learn.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops">WIQL syntax</a>.</p>
SELECT
Id
, Title
, Description
, CreatedDate
, Url
FROM WorkItems
--WHERE Id=5283490 -- uncomment to get just one WorkItem
WITH(Query='SELECT * FROM WorkItems WHERE [System.TeamProject]=''ProductTesting'' and [System.Id]=6455 ORDER BY [System.Id] DESC')
Query sprint hours by team member (estimated vs completed)
<p>Returns aggregated original estimate, remaining work, and completed work per team member for a sprint (iteration path). Useful for sprint burndown or capacity reporting. The query groups by iteration path and assignee; the WITH clause filters to a specific sprint and state (e.g. Resolved, Closed).</p><p>This only gives meaningful results if your team updates Original Estimate and Completed Work on work items as they progress. You can change the iteration path in the query to cover other sprints or the whole product.</p>
SELECT
IterationPath as Sprint
, AssignedToUniqueName as AssignedTo
, SUM(OriginalEstimate) as OriginalHours_Total
, SUM(RemainingWork) as RemainingWork_Total
, SUM(CompletedWork) as CompletedHours_Total
FROM WorkItems
GROUP BY IterationPath,AssignedToUniqueName
WITH(
Project='ProductTesting'
--//On Preview UI Change [Max Rows] to use more sample rows - else it will use only 100 rows
,Query='SELECT * FROM WorkItems WHERE [System.IterationPath] UNDER ''ProductTesting\Sprint 1'' and State IN(''Resolved'', ''Closed'')'
--Use below to query all sprints for this Product
--,Query='SELECT * FROM WorkItems WHERE [System.IterationPath] UNDER ''ProductTesting\'' and State IN(''Resolved'', ''Closed'')'
)
Read more than 20000 work items (UNION ALL)
<p>The Azure DevOps API returns at most 20000 work items per request. To read more, run multiple queries that each request a different ID range (e.g. 1–19999, 20000–39999) and combine the results. This example uses temp tables and UNION ALL so you get one result set; you can add more ranges by adding more SELECT INTO and UNION ALL lines.</p><p>Run the full script at once. Adjust the ID ranges and the number of temp tables to match your data size.</p>
SELECT * INTO #t1 FROM WorkItems WITH(Project='ProductTesting', Query='SELECT * FROM WorkItems WHERE [System.Id]>=1 and [System.Id]<20000');
SELECT * INTO #t2 FROM WorkItems WITH(Project='ProductTesting', Query='SELECT * FROM WorkItems WHERE [System.Id]>=20000 and [System.Id]<40000');
SELECT * INTO #t3 FROM WorkItems WITH(Project='ProductTesting', Query='SELECT * FROM WorkItems WHERE [System.Id]>=40000 and [System.Id]<60000');
--//....
--//add more temp tables above and update UNION ALL too
SELECT * FROM #t1
UNION ALL
SELECT * FROM #t2
UNION ALL
SELECT * FROM #t3
;
query_workitems endpoint belongs to
WorkItems
table(s), and can therefore be used via those table(s).
SQL Server
Use these SQL queries in SQL Server after you create a data source in Data Gateway:
List work items (default project)
<p>Returns work items from the default project specified in the connection (or the project you set in the WITH clause). Use this as the baseline list; you can filter by ID, state, or other columns in the WHERE clause, or pass a WIQL query in WITH to filter on the server.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM WorkItems';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
List work items for a project
<p>Lists work items for a specific project by supplying the project name in the WITH clause. Use this when your connection default is one project but you need to query another. You can combine with a WHERE clause or a WIQL query in WITH to narrow results.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM WorkItems WITH (Project=''ProductTesting'')';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
List work items with ParentId
<p>By default, relation fields such as ParentId are not returned so that list queries stay fast. When you need parent-child or other link information, set <code>Expand='Relations'</code> in the WITH clause. The result set will then include ParentId and other relation columns so you can join or filter by hierarchy.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM WorkItems WITH(Expand=''Relations'')';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
Query work items by WIQL (filters and date range)
<p>Use a WIQL (Work Item Query Language) query to filter work items by project, ID range, changed/created dates, work item type, state, priority, and more. The query runs on the server and returns only matching rows. This example shows typical filters: project, ID range, date variables like @Today and @StartOfYear, and ordering by changed date.</p><p>For full syntax and operators, see <a href="https://learn.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops">WIQL syntax</a> and <a href="https://learn.microsoft.com/en-us/azure/devops/boards/queries/query-operators-variables?view=azure-devops">query operators and variables</a>.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM WorkItems WITH (Query=''SELECT * FROM WorkItems
WHERE [System.Id] > 2000 AND [System.Id] < 7050
AND [System.TeamProject]=''''ProductTesting''''
AND [System.ChangedDate] < @Today
AND [System.CreatedDate] > @StartOfYear
AND [System.WorkItemType]=''''Task''''
AND [System.State]=''''Resolved''''
AND [Microsoft.VSTS.Common.Priority] >= 1
ORDER BY [System.ChangedDate] DESC
'')';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
Query work items modified after a date (dynamic)
<p>Use placeholder functions (e.g. monthstart, today, yearend) and arithmetic (e.g. monthstart-1d) to build dynamic dates in your WIQL query so the same statement always reflects the intended period without manual date changes. The placeholder is evaluated before the query is sent to Azure DevOps.</p><p>For placeholder syntax and options see <a href="https://zappysys.com/links/?id=10014">placeholder functions</a>. For WIQL see <a href="https://learn.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops">WIQL syntax</a>.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM WorkItems WITH (Query=''SELECT * FROM WorkItems
WHERE [System.TeamProject]=''''ProductTesting''''
AND [System.ChangedDate] >= ''''<<monthstart-1d,FUN_TO_DATE>>''''
ORDER BY [System.ChangedDate] DESC
'')';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
Query work items by WIQL in a project
<p>Runs a WIQL query in a specific project by passing both the project name and the query in the WITH clause. Use this when the connection default is different from the project you want to query, or when you need to target one project explicitly. The query can filter by ID, state, type, or any other WIQL criteria.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM WorkItems WITH (Project=''PosProject'', Query=''SELECT * FROM WorkItems WHERE [System.Id] = 2819'')';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
Query work items by type (e.g. Task)
<p>Returns work items of a given type (e.g. Task, Bug, User Story) by filtering with a WIQL query on <code>System.WorkItemType</code>. Use this to list all tasks, all bugs, or any other type. You can combine with other WIQL conditions (state, project, dates) in the same query string.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * FROM WorkItems WITH (Query=''SELECT * FROM WorkItems WHERE [System.WorkItemType] = ''''Task'''''')';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
Query work items using WIQL
<p>Run a WIQL query to filter work items by project and criteria; the query is passed in the WITH clause and executed on the server. You can select specific columns (e.g. Id, Title, Description, CreatedDate, Url) or use * to return all columns. WIQL supports project, ID, state, work item type, dates, and more.</p><p>For syntax and operators see <a href="https://learn.microsoft.com/en-us/azure/devops/boards/queries/wiql-syntax?view=azure-devops">WIQL syntax</a>.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT
Id
, Title
, Description
, CreatedDate
, Url
FROM WorkItems
--WHERE Id=5283490 -- uncomment to get just one WorkItem
WITH(Query=''SELECT * FROM WorkItems WHERE [System.TeamProject]=''''ProductTesting'''' and [System.Id]=6455 ORDER BY [System.Id] DESC'')';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
Query sprint hours by team member (estimated vs completed)
<p>Returns aggregated original estimate, remaining work, and completed work per team member for a sprint (iteration path). Useful for sprint burndown or capacity reporting. The query groups by iteration path and assignee; the WITH clause filters to a specific sprint and state (e.g. Resolved, Closed).</p><p>This only gives meaningful results if your team updates Original Estimate and Completed Work on work items as they progress. You can change the iteration path in the query to cover other sprints or the whole product.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT
IterationPath as Sprint
, AssignedToUniqueName as AssignedTo
, SUM(OriginalEstimate) as OriginalHours_Total
, SUM(RemainingWork) as RemainingWork_Total
, SUM(CompletedWork) as CompletedHours_Total
FROM WorkItems
GROUP BY IterationPath,AssignedToUniqueName
WITH(
Project=''ProductTesting''
--//On Preview UI Change [Max Rows] to use more sample rows - else it will use only 100 rows
,Query=''SELECT * FROM WorkItems WHERE [System.IterationPath] UNDER ''''ProductTesting\Sprint 1'''' and State IN(''''Resolved'''', ''''Closed'''')''
--Use below to query all sprints for this Product
--,Query=''SELECT * FROM WorkItems WHERE [System.IterationPath] UNDER ''''ProductTesting\'''' and State IN(''''Resolved'''', ''''Closed'''')''
)';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
Read more than 20000 work items (UNION ALL)
<p>The Azure DevOps API returns at most 20000 work items per request. To read more, run multiple queries that each request a different ID range (e.g. 1–19999, 20000–39999) and combine the results. This example uses temp tables and UNION ALL so you get one result set; you can add more ranges by adding more SELECT INTO and UNION ALL lines.</p><p>Run the full script at once. Adjust the ID ranges and the number of temp tables to match your data size.</p>
DECLARE @MyQuery NVARCHAR(MAX) = 'SELECT * INTO #t1 FROM WorkItems WITH(Project=''ProductTesting'', Query=''SELECT * FROM WorkItems WHERE [System.Id]>=1 and [System.Id]<20000'');
SELECT * INTO #t2 FROM WorkItems WITH(Project=''ProductTesting'', Query=''SELECT * FROM WorkItems WHERE [System.Id]>=20000 and [System.Id]<40000'');
SELECT * INTO #t3 FROM WorkItems WITH(Project=''ProductTesting'', Query=''SELECT * FROM WorkItems WHERE [System.Id]>=40000 and [System.Id]<60000'');
--//....
--//add more temp tables above and update UNION ALL too
SELECT * FROM #t1
UNION ALL
SELECT * FROM #t2
UNION ALL
SELECT * FROM #t3
;';
EXEC (@MyQuery) AT [LS_TO_AZURE_DEVOPS_IN_GATEWAY];
query_workitems endpoint belongs to
WorkItems
table(s), and can therefore be used via those table(s).