SQL Snippet – list all databases with size

SQL Snippet – list all databases with size
1 vote, 5.00 avg. rating (94% score)

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 



January 26, 2015 В· Adi В· No Comments
Posted in: Code Snippet, SQL

Leave a Reply

What is 14 + 4 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)