Collect database file information

Standard

I’ve been documenting a lot the last few years and one of the things I want to know is where the files of the databases reside.

The script below displays the following information about the database files:

  • Database name
  • File name
  • Physical file name
  • File type
  • File size
  • File growth
SELECT
db.name AS 'Database name'
,mf.name AS 'File name'
,mf.physical_name AS 'Physical file name'
,mf.type_desc AS 'File type'
,mf.size AS 'File size'
,mf.growth AS 'File growth'
FROM
master.sys.databases AS db
INNER JOIN master.sys.master_files AS mf
ON mf.database_id = db.database_id
ORDER BY
db.name

Leave a Reply

Your email address will not be published.