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. #1 by Crystle on 22/05/2013 - 03:55

    I think the admin of this web site is really working hard in support of his site, because here every stuff is quality based material.

  2. #2 by bodybuilding on 05/10/2014 - 21:14

    Heya terrific website! Does running a blog like this require a lot
    of work? I’ve no understanding of computer programming however I had been hoping to start my own blog in the near future.
    Anyway, should you have any suggestions or techniques for
    new blog owners please share. I know this is off topic nevertheless I just needed to ask.
    Cheers!

    • #3 by sveroadev on 10/10/2014 - 19:03

      Just write post on interesting topics, use sensible categories and tags…my few couple of tips

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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 736 other followers

%d bloggers like this: