Click here to Skip to main content
Click here to Skip to main content

SQL Server: Get All Databases Size

By , 2 Oct 2012
 

Introduction

To get recent size of all databases on an instance, I have found following simple query very useful.

Script

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

aasim abdullah
Team Leader CureMD
Pakistan Pakistan
Member
Aasim Abdullah is working as SQL Server DBA with CureMD (www.curemd.com) based in NY, USA. He has been working with SQL Server since 2007 (Version 2005) and has used it in many projects as a developer, administrator, database designer. Aasim's primary interest is SQL Server performance tuning. If he finds the time, he like to sketch faces with graphite pencils.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 2 Oct 2012
Article Copyright 2012 by aasim abdullah
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid