Skip to content

Instantly share code, notes, and snippets.

@gitfvb
Created August 9, 2019 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitfvb/f372ec1418fca7c89c598a47f06d9b69 to your computer and use it in GitHub Desktop.
Save gitfvb/f372ec1418fca7c89c598a47f06d9b69 to your computer and use it in GitHub Desktop.
MSSQL SQL Server
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