CREATE TABLE #Data (name varchar), row varchar (reserved), Data varchar (+), index_size varchar ( (+), unused varchar)
DECLARE @name varchar (+)
Declare cur cursor for
select name from sysobjects where xtype= ' u ' ORDER by name
Open cur
fetch next from cur to @name
while @ @fetch_status =0
Begin
In SERT to #data
exec sp_spaceused @name
print @name
Fetch NEXT from cur to @name
End
Close C ur
deallocate cur
CREATE table #DataNew (name varchar), row int,reserved int,data int,index_size int,unuse d int)
INSERT INTO #dataNew
Select Name,convert (Int,row) as Row,convert (Int,replace (reserved, ' KB ', ")) as Re Served,convert (int,replace (data, ' KB ', ')) as data,
Convert (Int,replace (index_size, ' KB ', ")) as Index_size, Convert (Int,replace (unused, ' KB ', ')) as unused from #data
Select Name,cast (data as FLOAT)/(SUM (data) over ()) fro M #dataNew
ORDER by data desc
View database table Spaces