Fork me on GitHub

SQL命令示例

SQLSERVER 数据库查看各表的记录数 


select
so.name as 'TableName',max(si.rows) as 'TotalCount' from [YourDataBaseName].dbo.[sysobjects] so inner join [YourDataBaseName].dbo.[sysindexes] si on so.id=si.id and so.xtype='u' group by so.name order by max(si.rows) desc

 

select SUM(TotalCount) as 'Total' from(
  select top 10000 so.name as 'TableName',max(si.rows) as 'TotalCount'
  from [YourDataBaseName].dbo.[sysobjects] so
  inner join [YourDataBaseName].dbo.[sysindexes] si on so.id=si.id and so.xtype='u'
  group by so.name
  order by max(si.rows) desc
) t1
posted @ 2018-08-18 10:33  chenpw  阅读(123)  评论(0)    收藏  举报
View Code