Technical Article

Space Used By Table

,

Fairly simple to use. Just cut-n-paste into the Query Window. Select your database and run.

CREATE TABLE #space ( tableName sysname,
 numrows integer,
 reserved varchar(25),
 data varchar(25),
 indexsize varchar(25),
 unused varchar(25))

declare objcurs cursor for select [name] from sys.objects where type = 'U'
declare @name sysname
open objcurs
fetch next from objcurs into @name
while @@fetch_status = 0
begin
 insert into #space
 exec sp_spaceused @name
 fetch next from objcurs into @name
end
close objcurs
deallocate objcurs

select * from #space order by 
convert(integer, replace(data,'KB','')) desc

Rate

5 (3)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (3)

You rated this post out of 5. Change rating