-查询数据库中所有的表名及行数
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