--☆★☆★显示每个表占用的磁盘空间
create table tmp(
TableName varchar(50),
RowsCount int,
ReservedSize varchar(50),
DataSize varchar(50),
IndexSize varchar(50),
UnusedSize varchar(50),
DataM decimal(18,2)
)
insert into tmp(TableName,RowsCount,ReservedSize,DataSize,IndexSize,UnusedSize)
exec sp_MSforeachtable @command1="sp_spaceused '?'"
update tmp
set DataM=cast(replace(ReservedSize,' KB','') as decimal(18,2))/1024
select TableName 表名,RowsCount 记录数,ReservedSize 总空间,DataSize 数据空间Kb,IndexSize 索引空间,UnusedSize 未用空间,DataM 总空间Mb
from tmp
order by DataM desc
drop table tmp
|