Database size and type

Simple script, shows database name, type of file and size of that file.

It does not count the system databases not any database that has a ‘snapshot’ in its name. Customize as you like 🙂

select sysdb.name,
CASE sysmaster.type_desc
WHEN 'ROWS' THEN 'DATA'
WHEN 'LOG' THEN 'LOG'
END as filetype,
sum((sysmaster.size/128)) as MB
from sys.databases sysdb
join sys.master_files sysmaster on sysdb.database_id = sysmaster.database_id
where sysdb.name not like '%snapshot%'
and sysdb.name not in ('tempdb','master','model','msdb')
group by sysdb.name, sysmaster.type_desc

 

Leave a Reply

Your email address will not be published. Required fields are marked *