SQL查看数据库中每张表的数据量和总数据量

 

查看所有表对应的数据量

SELECT a.name AS 表名, MAX(b.rows) AS 记录条数FROM sys.sysobjects AS a INNER JOIN sys.sysindexes AS b ON a.id = b.idWHERE (a.xtype = 'u')GROUP BY a.nameORDER 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

 

posted @ 2018-06-14 08:01  辣椒粉  阅读(4627)  评论(0编辑  收藏  举报