您的位置:首页 > 数据库

sqlserver查询所有表的行数的sql语句

2012-01-11 16:22 405 查看
select a.name, b.rows

from sysobjects a

inner join sysindexes b on a.id = b.id

where a.type = 'u'

and b.indid in (0, 1)

order by a.name


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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: