查看所有表对应的数据量

SELECT   a.name AS 表名, MAX(b.rows) AS 记录条数
FROM      sys.sysobjects AS a INNER JOIN
                sys.sysindexes AS b ON a.id = b.id
WHERE   (a.xtype = \'u\')
GROUP BY a.name
ORDER BY 记录条数 DESC

 

查看数据库的总数据量

SELECT   SUM(记录条数) AS 总记录数
FROM      (SELECT   TOP (10000) a.name AS 表名, MAX(b.rows) AS 记录条数
                 FROM      sys.sysobjects AS a INNER JOIN
                                 sys.sysindexes AS b ON a.id = b.id
                 WHERE   (a.xtype = \'u\')
                 GROUP BY a.name
                 ORDER BY 记录条数 DESC) AS t1

 

版权声明:本文为ideacore原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/ideacore/p/8136888.html