--查询数据库中所有的表名及行数
SELECT a.name , b.rows FROM sysobjects AS a
INNER JOIN sysindexes AS b ON a.id = b.id
WHERE ( a.type = 'u' ) AND ( b.indid IN ( 0, 1 ) )
ORDER BY b.rows DESC
--查询所有的表名及空间占用量情况
SELECT OBJECT_NAME(id) tablename ,
8 * reserved / 1024 reserved ,
RTRIM(8 * dpages) AS 'used(kb)' ,
8 * ( reserved - dpages ) / 1024 unused ,
8 * dpages / 1024 - rows / 1024 * minlen / 1024 free
FROM sysindexes
WHERE indid = 1
ORDER BY reserved DESC
统计整个数据库用户表所占用空间大小(MB)
SELECT 8*SUM(b.dpages)/1024 占用空间MB FROM sysobjects AS a INNER JOIN sysindexes AS b ON a.id = b.id WHERE a.xtype='U' AND b.indid=1