Skip to content

Instantly share code, notes, and snippets.

@digioz
Created June 29, 2016 21:16
Show Gist options
  • Save digioz/ca93bb8298e983eb45645823874fd1d2 to your computer and use it in GitHub Desktop.
Save digioz/ca93bb8298e983eb45645823874fd1d2 to your computer and use it in GitHub Desktop.
Get Size of All Databases on SQL Server
SELECT d.name,
ROUND(SUM(mf.size) * 8 / 1024, 0) Size_MBs
FROM sys.master_files mf
INNER JOIN sys.databases d ON d.database_id = mf.database_id
WHERE d.database_id > 4 -- Skip system databases
GROUP BY d.name
ORDER BY d.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment