Collect database file information


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 AS 'Database 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'
master.sys.databases AS db
INNER JOIN master.sys.master_files AS mf
ON mf.database_id = db.database_id

Leave a Reply

Your email address will not be published.