In 2013, I have some boards setup using xxx-Doing and xxx-Done columns. Since in 2015, TFS provides out-of-box doing and done column split option, If I want to use that column option, I need to migrate those work items to new xxx columns. The following query is for migrating them instead of manually move them one at a time. After the migration, just delete those xxx-doing/done columns.

— Update with processing xxx-Doing
SELECT *
— UPDATE t
— SET t.BitValue =
— (CASE
–WHEN s.StringValue LIKE ‘%-Done’ AND t.FieldId = <FieldId>THEN 1
— End)
— , t.StringValue =
— (CASE
–WHEN s.StringValue LIKE ‘%-Doing’ AND t.FieldId = <FieldId>THEN REPLACE(s.StringValue, ‘-Doing’, ”)
–WHEN s.StringValue LIKE ‘%-Done’ AND t.FieldId = <FieldId>THEN REPLACE(s.StringValue, ‘-Done’, ”)
— End)
FROM [Tfs_DefaulCollection].[dbo].[tbl_WorkItemCustomLatest] s, [Tfs_DefaulCollection].[dbo].[tbl_WorkItemCustomLatest] t, [Tfs_DefaulCollection].[dbo].[LinksAre] la
WHERE la.SourceID = s.Id
AND la.TargetID = t.Id
AND la.DataspaceId = <DataspaceId>
AND la.TargetDataspaceId = <TargetDataspaceId>
AND s.FieldId = <FieldId>
AND t.FieldId IN (FieldId1, FieldId2)

Advertisements