码迷,mamicode.com
首页 > 数据库 > 详细

SQLSERVER中统计所有表的记录数

时间:2014-11-06 10:38:01      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   ar   for   sp   div   on   

利用系统索引表sysindexes中索引ID indid<1的行中的rows列存有该表的行数这一特点.    最后一种方法是利用隐藏未公开的系统存储过程sp_MSforeachtable

CREATE TABLE #temp (TableName VARCHAR (255), RowCnt INT)
EXEC sp_MSforeachtable INSERT INTO #temp SELECT ‘‘?‘‘, COUNT(*) FROM ?
SELECT TableName, RowCnt FROM #temp ORDER BY RowCnt DESC
DROP TABLE #temp

 

SQLSERVER中统计所有表的记录数

标签:des   style   blog   color   ar   for   sp   div   on   

原文地址:http://www.cnblogs.com/mybi/p/4077962.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!