Tuesday, January 3, 2006

How to list SQL Server database sizes

Sometimes someone will ask you, "How big is that database?". This query will show you in Microsoft SQL Server:




select d.name, cast(sum(f.size) as float)*8/1024 [MB]
from master.dbo.sysaltfiles f
left join master.dbo.sysdatabases d on d.dbid = f.dbid
group by d.name
order by d.name

No comments:

Post a Comment

I moderate comments blog posts over 14 days old. This keeps a lot of spam away. I generally am all right about moderating. Thanks for understanding.