SQL Server Admin
T-SQL Articles

August 13, 2009

Display List of All Databases with their Sizes in SQL Server 2005/2008




Here’s a query that lists the properties of a database using the sys.master_files and sys.databases, both System Views for retrieving Database information.

SELECT sysDa.Name,sysDa.create_date,sysDa.recovery_model_desc, temp.DBSize8KBPage
FROM
(
SELECT sysMas.database_ID, sysMas.size, SUM(size) as DBSize8KBPage
FROM sys.master_Files sysMas
GROUP BY sysMas.DataBase_ID, sysMas.size
)
temp
INNER JOIN
Sys.Databases sysDa
on temp.Database_ID = sysDa.DataBase_ID

OUTPUT

image


Did you like this post?
kick it on DotNetKicks.com
subscribe via rss subscribe via e-mail
print this post follow me on twitter



 
  Feedback:

comments

0 Responses to "Display List of All Databases with their Sizes in SQL Server 2005/2008"
 

Copyright © 2009-2011 All Rights Reserved for SQLServerCurry.com by Suprotim Agarwal | Terms and Conditions