Microsoft SQL Server 2005
Performance Tuning
Best Practices

How to list space usage for all databases?

 

Execute the following script in Query Editor to display space used information for all databases:

use master
go

create table #systemdbs (name sysname)
insert #systemdbs
select 'master'
union all select 'msdb'
union all select 'model'
union all select 'tempdb'

declare @Command nvarchar(1012)
set @Command= 'if not exists (select * from #systemdbs where name = ''?'') use ? ; exec sp_spaceused @updateusage=true'
print @Command

exec sp_MSforeachdb @command1 = @Command

drop table #systemdbs

go

 

 

The Best SQL Server 2005 Training in the World
 
 
SQLUSA.com Home Page