We are using TFS 2012 and have hundreds of Shared Queries that have been created over time due to poor oversight. In order to clean these up and provide a common set of shared queries, we'd like to determine who created the queries and when, similar to work item type history.
Is there a way to find this information in the TFS UX, using an extension or querying the DB?
You can find the owner of a query in Team Web by looking at the security of a query, but it doesn't show the create date.
The data you need is stored in the QueryItems
table of each collection db.
So, you should be able to get this information from a sql query like below, just change out the db names for your collection db.
SELECT t.Name as 'ProjectName'
,qi.[Name] as 'Query Name'
,[Text]
,[CreateTime]
,[LastWriteTime]
,c.DisplayPart as 'Owner'
FROM [TFS_DefaultCollection].[dbo].[QueryItems]qi
Left Join [TFS_DefaultCollection].[dbo].[Constants] c on c.TeamFoundationId=qi.OwnerIdentifier
Left join [TFS_DefaultCollection].[dbo].[TreeNodes] t on t.ID=qi.ProjectId
Where fPublic=1 and fFolder=0