|
Execute the following Microsoft SQL Server Transact-SQL (T-SQL) script in Management Studio (SSMS) Query Editor, SQLCMD or other client software
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
|