TFS – list files across team projects by SQL


When working with TFS you often need to list files from the source control. This can be done in many ways, but as a geek, I want a SQL script to list and search for files. Off course, I can use the TFS Power Tool and the “Find in source control…” function.

But here is a script for listing and searching for files accross team projects. The below example searches for all files with filename containing ‘ADSync’.

SELECT 
  [FileName]
  ,SUBSTRING([FilePath], 1, 
        CHARINDEX('/', [FilePath], 3)) as TeamProject
  ,[FilePath]
  ,[LastUpdatedDateTime]
FROM [Tfs_Warehouse].[dbo].[DimFile]
WHERE [FileName] LIKE '%ADSync%' 
  AND [FileExtension] LIKE '%';

The below statement will count number of aspx files across all team project.

SELECT 
  SUBSTRING([FilePath], 1, CHARINDEX('/', [FilePath], 3)), 
  FileExtension,
  COUNT(*)
FROM [Tfs_Warehouse].[dbo].[DimFile]
WHERE FileExtension in ('.aspx')
GROUP BY 
   SUBSTRING([FilePath], 1, CHARINDEX('/', [FilePath], 3)), 
   FileExtension
About these ads

, , , , , , ,

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 536 other followers

%d bloggers like this: