Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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'
WHEN 'LOG' THEN 'LOG'
END AS [Database File Type],
(size * 8) / 1024 [Database Size (MB)]
FROM sys.master_files
WHERE DB_NAME(database_id) LIKE 'tfs_%'
ORDER BY 1
/*=============== ALL DONE! ===============*/
Keep it handy for other systems why don't ya :-)
Comments
- Anonymous
May 01, 2015
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?