我正在为我们的质量检查小组编写一些自定义SSRS报告,我需要在我的查询中添加测试用例“标签”。据我所知,这些不在TFS_Warehouse中。我在运营商店中找到了dbo.tbl_TagDefinition,但无法弄清楚如何将其加入工作项。
答案 0 :(得分:4)
如果您的TFS包含随TFS 2013 Update 2或更高版本添加的更新,则可以直接向工作项查询添加标记。
如果您想从数据库查询,请检查this case:
2013年及以后的TFS:
SELECT DISTINCT workItem.ID, tbl_TagDefinition.Name
--,tbl_PropertyValue.ArtifactId, *
FROM tbl_TagDefinition
LEFT JOIN tbl_PropertyDefinition ON tbl_PropertyDefinition.Name = 'Microsoft.TeamFoundation.Tagging.TagDefinition.' + CONVERT(NVARCHAR(400), tbl_TagDefinition.TagId)
LEFT JOIN tbl_PropertyValue ON tbl_PropertyValue.PropertyId = tbl_PropertyDefinition.PropertyId
--LEFT JOIN WorkItemLongTexts ON WorkItemLongTexts.ID = tbl_PropertyValue.ArtifactId
left join tbl_WorkItemCoreLatest workItem on WorkItemsAre.ID = tbl_PropertyValue.ArtifactId
WHERE
(
SELECT SUM(CASE WHEN IntValue = 0 THEN 1 ELSE -1 END) NB
FROM tbl_PropertyValue PROP_CNT
WHERE PROP_CNT.PropertyId = tbl_PropertyDefinition.PropertyId
AND workItem.ID = PROP_CNT.ArtifactId
) > 0
2013年TFS之前:
SELECT DISTINCT WorkItemsAre.ID, WorkItemsAre.Title, tbl_TagDefinition.Name
--,tbl_PropertyValue.ArtifactId, *
FROM tbl_TagDefinition
LEFT JOIN tbl_PropertyDefinition ON tbl_PropertyDefinition.Name = 'Microsoft.TeamFoundation.Tagging.TagDefinition.' + CONVERT(NVARCHAR(400), tbl_TagDefinition.TagId)
LEFT JOIN tbl_PropertyValue ON tbl_PropertyValue.PropertyId = tbl_PropertyDefinition.PropertyId
--LEFT JOIN WorkItemLongTexts ON WorkItemLongTexts.ID = tbl_PropertyValue.ArtifactId
left join WorkItemsAre on WorkItemsAre.ID = tbl_PropertyValue.ArtifactId
WHERE
(
SELECT SUM(CASE WHEN IntValue = 0 THEN 1 ELSE -1 END) NB
FROM tbl_PropertyValue PROP_CNT
WHERE PROP_CNT.PropertyId = tbl_PropertyDefinition.PropertyId
AND WorkItemsAre.ID = PROP_CNT.ArtifactId
) > 0
答案 1 :(得分:1)
TFS 2015数据库很复杂,但是您可以在此查询标记以查找所有匹配的工作项
select * from tbl_WorkItemCoreLatest
where
id in
(
select CONVERT(INT, artifactid) from tbl_PropertyValue
where
PropertyId in
(
select PropertyId from tbl_PropertyDefinition
where
name in
(
select ltrim(rtrim('Microsoft.TeamFoundation.Tagging.TagDefinition.' + cast(tagid as varchar(1000))))
from tbl_TagDefinition
where name like '%<TAG NAME TO SEARCH FOR>%' -- Tag name you're looking for
)
)
)
希望这会有所帮助: - )
-R
答案 2 :(得分:0)
这是基于@Robby的答案的,并且似乎在Azure DevOps 2019上仍然有效:
select distinct
wcl.id,
td.Name from tbl_WorkItemCoreLatest wcl
left outer join tbl_PropertyValue pv on wcl.id = pv.artifactid
left outer join tbl_PropertyDefinition pd on pv.PropertyId = pd.PropertyId
left outer join tbl_TagDefinition td on pd.Name = ltrim(rtrim('Microsoft.TeamFoundation.Tagging.TagDefinition.' + cast(td.TagId as varchar(1000))))
where td.Name is not null