There are times when you need to get information on the actual files that a database is using.
SELECT database_id,
DB_NAME(database_id) AS database_name,
file_id,
type_desc,
data_space_id,
name,
physical_name,
UPPER(LEFT(physical_name, 3)) AS drive,
state_desc,
(size * 8) AS "Size Kb",
((size * 8) / 1024) AS "Size Mb"
FROM sys.master_files
ORDER BY database_id, type, data_space_id
I have added a couple of extra columns:Note that you can use sys.database_files instead of sys.master_files, they are the same except that database_files only looks at the current database, master_files looks at every database in the SQL Instance. Information is available at sys.master_files (Transact-SQL) which explains the columns.