create table test(
name varchar(50),
rows int,
reserved varchar(20),
data varchar(20),
index_size varchar(20),
unused varchar(20)
)
set nocount on
insert into test
EXEC sp_MSforeachtable @command1="sp_spaceused '?'"
select * from test order by cast(replace(reserved,'KB','') as int) desc
drop table test