SQLServer一条SQL统计所有表的行数[转]
时间:2011-04-16 来源:天际翔龙
SELECT o.name AS "Table Name", i.rowcnt AS "Row Count"
FROM sysobjects o, sysindexes i
WHERE i.id = o.id
AND i.indid IN(0,1)
AND o.xtype = 'u' --只统计用户表
AND o.name <> 'sysdiagrams'
ORDER BY i.rowcnt DESC --按行排降序
COMPUTE SUM(i.rowcnt), count(o.name); --汇总行数,表数
GO
FROM sysobjects o, sysindexes i
WHERE i.id = o.id
AND i.indid IN(0,1)
AND o.xtype = 'u' --只统计用户表
AND o.name <> 'sysdiagrams'
ORDER BY i.rowcnt DESC --按行排降序
COMPUTE SUM(i.rowcnt), count(o.name); --汇总行数,表数
GO
相关阅读 更多 +