Created
February 16, 2015 02:02
-
-
Save jeremybeavon/8e7f82466c26800022a6 to your computer and use it in GitHub Desktop.
Find sizes of all databases on a server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
database_name = DB_NAME(database_id) | |
, log_size_mb = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) | |
, row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2)) | |
, total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2)) | |
FROM sys.master_files WITH(NOWAIT) | |
GROUP BY database_id | |
ORDER BY total_size_mb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment