blog.icewolf.ch

Let's talk about IT!
posts - 1924, comments - 295, trackbacks - 0

My Links

Archives

Post Categories

icewolf

MSSQL Spaceused

Wir hatten da mal eine riesengrosse Datenbank mit zig Tabellen. Weil wir nicht wussten welche Tabelle denn so riesengross ist, habe ich mich auf die Suche nach einer geeigneten SQL Abfrage gemacht - et voila - hier ist sie:

set nocount on
create table #spaceused (
name nvarchar(120),
rows char(11),
reserved varchar(18),
data varchar(18),
index_size varchar(18),
unused varchar(18)
)
declare Tables cursor for
select name
from sysobjects where type='U'
order by name asc
OPEN Tables
DECLARE @table varchar(128)
FETCH NEXT FROM Tables INTO @table
WHILE @@FETCH_STATUS = 0
BEGIN
insert into #spaceused exec sp_spaceused @table
FETCH NEXT FROM Tables INTO @table
END
CLOSE Tables
DEALLOCATE Tables
select * from #spaceused ORDER BY data
 
exec sp_spaceused
drop table #spaceused

Print | posted on Sunday, February 24, 2008 1:24 PM | Filed Under [ SQL ]

Powered by:
Powered By Subtext Powered By ASP.NET