SQL 查询某个库的所有表的行数

select a.name AS name,b.rows AS rows  INTO #Temp1
from db_tank(数据库名称).dbo.sysobjects a LEFT JOIN  db_tank(数据库名称).dbo.sysindexes b
ON( a.id=b.id ) WHERE  a.type='u'  ORDER BY b.rows DESC

SELECT name,max(rows) FROM #Temp1 GROUP BY NAME ORDER BY max(rows) DESC

你可能感兴趣的:(sql)