sql-serversql-server-2008t-sqldatabase-management

Listing information about all database files in SQL Server


Is it possible to list information about the files (MDF/LDF) of all databases on an SQL Server?

I'd like to get a list showing which database is using what files on the local disk.

What I tried:


Solution

  • You can use sys.master_files.

    Contains a row per file of a database as stored in the master database. This is a single, system-wide view.