EXEC sp_databases;
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;
SELECT
    d.name AS 'Database',
    SUM(m.size) * 8/1024/1024 'Size (GB)'
FROM 
	sys.master_files m
	INNER JOIN sys.databases d ON d.database_id = m.database_id
WHERE
	d.name IN ('DB01', 'DB02')
GROUP BY
	d.name

Fix:

  • Shrink database file to recover unused space.
  • Add more disk space.
  • Purge data from database.
  • Move data to another database or data warehouse.

Sources:

Last modified: May 27, 2021

Author

Comments

Write a Reply or Comment