Click here to Skip to main content
11,932,402 members (56,783 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked

SQL Server: Get All Databases Size

, 2 Oct 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
A simple query to get all databases size on a given instance.


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


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


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
Aasim Abdullah is working as SQL Server DBA with CureMD ( 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.

You may also be interested in...

Comments and Discussions

QuestionDB size from a list of servers Pin
Member 1042182630-Jan-14 18:58
memberMember 1042182630-Jan-14 18:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 2 Oct 2012
Article Copyright 2012 by aasim abdullah
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid