SQL Snippet – list all databases with size
SQL – Get the list of all the databases and their size
The below script will give the list of all database with name and size of respective database
SELECT d.name [DB Name], ROUND(SUM(mf.size) * 8 / 1024, 0) [DB Size (Mb)] FROM sys.master_files mf INNER JOIN sys.databases d ON d.database_id = mf.database_id WHERE d.database_id > 4 -- avoid system databases GROUP BY d.name ORDER BY [DB Size (Mb)] desc
Output
January 26, 2015
В·
Adi В·
No Comments
Posted in: Code Snippet, SQL
Leave a Reply