计算所有表数据量、占用空间
create table #tmp (name varchar(50),rows int,reserved varchar(50),data varchar(50),index_size varchar(50),unused varchar(50));
insert into #tmp (name,rows,reserved,data,index_size,unused) exec sp_msforeachTable "sp_spaceused '?'"
select
*,
--sum(
convert(decimal,replace(reserved,' KB',''))
+convert(decimal,replace(data,' KB',''))
+convert(decimal,replace(index_size,' KB',''))
+convert(decimal,replace(unused,' KB',''))
--)
from #tmp
drop table #tmp