Checking the recent policy overrides from Team Foundation Server database
Posted: (EET/GMT+2)
If you have Visual Studio 2005 Team Foundation Server (TFS) up and running in your organization (or the "free" Workgroup Edition on your personal development PC as I do), chances are you would like to list all those policy overrides that were done during a check-in operation. Now, there are two routes to this: using the TFS APIs (which are web services) or tinkering with the SQL Server database that TFS uses internally. Since I like SQL, I'd love to share my simple SQL statement for listing the most recent policy overrides. Here you go:
SELECT [cs].[CreationDate]
,[po].[Comment]
,[po].[ChangeSetId]
,[id].[DisplayName] as 'The Most Wanted'
FROM [TfsVersionControl].[dbo].[tbl_PolicyOverride] po
,[TfsVersionControl].[dbo].[tbl_ChangeSet] cs
,[TfsVersionControl].[dbo].[tbl_Identity] id
WHERE ([po].[ChangeSetId] = [cs].[ChangeSetId]) AND
([cs].[CommitterID] = [id].[IdentityId])
ORDER BY [cs].[CreationDate] DESC
Of course, this statement will probably break once the next version of TFS comes out, but for version 1.0/2005, this works nicely (and is fast). Good luck!