Wednesday, February 9, 2011

Script to find out size of all the databases on a particular SQL Server Instance

select @@SERVERNAME servername, DB_NAME(db.dbid) DatabaseName, Sum(af.size)*8/1024 DBSizefrom sysdatabases db inner join sysaltfiles af on db.dbid = af.dbid where DB_NAME(db.dbid) not in ('master', 'tempdb','model', 'msdb', 'distribution') Group By DB_NAME(db.dbid)

Comments:
==========
The output would have the following columns:

ServerName
DatabaseName
Size (in MB)



--Abhishek Soni

No comments:

Post a Comment