size of sql server database code example
Example 1: sql database size
SELECT
d.name AS 'Database',
m.name AS 'File',
m.size,
m.size * 8/1024 'Size (MB)',
SUM(m.size * 8/1024) OVER (PARTITION BY d.name) AS 'Database Total',
m.max_size
FROM sys.master_files m
INNER JOIN sys.databases d ON
d.database_id = m.database_id;
Example 2: sql database size
EXEC sp_databases;