https://sqlandme.com/2013/06/10/sql-server-how-to-get-sizes-of-all-databases-on-a-server/
Created
August 9, 2019 14:36
-
-
Save gitfvb/f372ec1418fca7c89c598a47f06d9b69 to your computer and use it in GitHub Desktop.
MSSQL SQL 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), | |
[Type] = CASE WHEN Type_Desc = 'ROWS' THEN 'Data File(s)' | |
WHEN Type_Desc = 'LOG' THEN 'Log File(s)' | |
ELSE Type_Desc END, | |
[Size in MB] = CAST( ((SUM(Size)* 8) / 1024.0) AS DECIMAL(18,2) ) | |
FROM sys.master_files | |
GROUP BY GROUPING SETS | |
( | |
(DB_NAME(database_id), Type_Desc), | |
(DB_NAME(database_id)) | |
) | |
ORDER BY DB_NAME(database_id), Type_Desc DESC | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment