if object_id('tmp_xl') is not null
drop table tmp_xl
create table tmp_xl
(
[name] varchar(50),
[rows] int,
reserved varchar(50),
data varchar(50),
index_size varchar(50),
unused varchar(50)
)
insert into tmp_xl
(
[name],
[rows],
reserved,
data,
index_size,
unused
)
exec sp_msforeachTable @Command1="sp_spaceused '?'"
update tmp_xl
set reserved = LEFT(reserved,len(reserved)-3),
data = LEFT(data,len(data)-3),
index_size = LEFT(index_size,len(index_size)-3),
unused = LEFT(unused,len(unused)-3)
select * from tmp_xl order by CAST(index_size as int) desc
drop table tmp_xl