/*Create return table.*/
declare @return table
(name varchar(100),
 rows bigint,
 reserved varchar(30),
 data varchar(30),
 index_size varchar(30),
 unused varchar(30))

/*Store current table.*/
declare @curr varchar(100)

/*Create cursor for all tables.*/
declare recscan cursor for 
select name from sysobjects where type = 'U' 

/*Use cursor to run sp_spaceused on all tables.*/
open recscan
fetch next from recscan into @curr

while @@fetch_status = 0
begin
	insert into @return exec sp_spaceused @curr 
	fetch next from recscan into @curr
end

/*Clean up cursor.*/
close recscan
deallocate recscan

/*return data*/
select 
	name,
	rows,
	reserved,
	data,
	index_size,
	unused
from @return
order by convert(bigint,left(reserved,len(reserved)-3)) desc