List all DB files in SQL

This will list all the DB files (not log files). To show log files remove the ‘Where’ clause.

SELECT
 db.name AS DBName,
 Physical_Name AS Location,
 Size
FROM
 sys.master_files mf
INNER JOIN
 sys.databases db ON db.database_id = mf.database_id
WHERE
 type_desc = 'ROWS'
ORDER BY
 Size DESC
Advertisements