SQL Server:统计数据库中每张表的大小

复制代码
create table tmp
(
    name varchar(50),
    rowscount int,
    reserved varchar(50),  
    data varchar(50),
    index_size varchar(50),
    unused varchar(50)
);
  
insert tmp(name, rowscount, reserved, data, index_size, unused) 
exec sp_MSforeachtable @command1="sp_spaceused '?'";
select * from tmp where name <> 'tmp' order by name
drop table tmp ;
复制代码

 

另外一种方法

复制代码
SELECT DISTINCT a.name ,
b.rows
FROM sysobjects a ,
sysindexes b
WHERE a.id = b.id
AND a.type = 'u' AND b.rows>0
ORDER BY b.rows DESC
复制代码
posted @ 2016-06-12 11:18  狼人666  阅读(143)  评论(0编辑  收藏  举报