SQL Stuff

Get Total Size Per Database

Here’s some very simple sql logic to give you the total size of each database.

;with dbsize as
(
select
'database' = db_name(database_id)
, 'size in gb' = convert(decimal(10,2),(sum(size * 8.00) / 1024.00 / 1024.00)) from
sys.master_files
group by
database_id
)

select
*
from
dbsize
order by
[size in gb] desc
Advertisements

Categories: SQL Stuff

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s