表记录查询最快查询方式

SELECT   ROWS
FROM   sysindexes
WHERE   id=OBJECT_ID( 'InboundPlan')
    AND   indid <2

--查询库内各表
select so.name as 'TableName', so.type,SUM(row_count) as 'TotalRows' 
from sys.dm_db_partition_stats as ps inner join sys.objects as so 
        on ps.object_id=so.object_id 
where index_id<=1 and so.type='U' 
group by so.name,so.type 
order by sum(row_count) desc

 除COUNT(*)外,上面就是查询表自己知道的最快的方法了,记录一下。

补充一个

---查询整个实例的数据库容量
SP_HELPDB

 

posted @ 2012-01-16 15:40  _cc  阅读(350)  评论(0编辑  收藏  举报