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