What's the size of my TFS Databases?

How many times have you been caught trying to figure out what is the current size of your TFS databases? I find more often than not, just before a TFS Migration or a backup procedure, this is a very frequent ask. Here's a nifty T-SQL Script to get your answer.


-- Please use judiciously as Microsoft does not recommend you directly hitting the DB
-- Determine the size of MS SQL Server Database
-- This is especially useful to determine how much space you need for backup/migration etc.

SELECT DB_NAME(database_id) AS [Database Name],
[name] [Logical File Name],
physical_name [Physical File Location],
CASE [type_desc] WHEN 'ROWS' THEN 'DATA'
END AS [Database File Type],
(size * 8) / 1024 [Database Size (MB)]
FROM sys.master_files
WHERE DB_NAME(database_id) LIKE 'tfs_%'

/*=============== ALL DONE! ===============*/


Keep it handy for other systems why don't ya 🙂

Comments (1)

  1. Pam says:

    Hi Chev,

    Thanks for this code. Is there a set of instructions that you might pair it with so that non-coders can have an easy way to apply this solution?

Skip to main content