简体   繁体   中英

Hierarchical List of Work Items from TFS_Warehouse database

I am trying to retrieve a hierarchical list of all 'Product Backlog' work items from TFS_Warehouse. Today is my first day working on TFS so I am not really aware of the schema/ or what table to look for.

I found two tables DimWorkItem and FactWorkItemLinkHistory. I tried extracting some information from these but no luck.

What I am trying to do is generate a Release Details list, which will show work items with state like New, Approved... I need to write a TSQL Statement to get this data.

Any help is appreciated.

Thanks, Vishal

I'm assuming you have already figured this out, but in case anyone else passes by you can use the GetWorkItemsTree UDF with a CROSS APPLY operator, passing it the root node System_Id and the relationship type to be used to traverse the tree, such as:

SELECT 
   ...
FROM
    DimWorkItem wi
CROSS APPLY
    GetWorkItemsTree(@TeamProjectCollectionGuid, wi.System_Id, N'Child', DEFAULT) wit
WHERE
    wi.System_Id = @RootId
    AND wi.System_RevisedDate = CONVERT(datetime, '9999', 126) -- latest revision

However, this UDF will only traverse a single relationship type and I recall there being a limitation to the traversal depth. If you need something more flexible you'll probably have to write it yourself; I did so using a UDF containing a recursive CTE on the [FactWorkItemLinkHistory] table which also provided for traversal of multiple relationship types.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM