开发者

Count number of entries in whole SQL Server database

Is there any way I can count the number of all entries in a SQL Server database? Preferably with only one query.

Edit: The total amount of entries in a开发者_StackOverflowll tables in a given database.


select sum(rows) from sys.partitions;

This is a correct answer, for a conveniently definition of 'entry' (chosen by me): a row in a heap or a b-tree.


This query will return a list of all the tables, with an approximate row count for each table:

SELECT 
    [TableName] = sysobjects.name, 
    [RowCount] = MAX(sysindexes.rows) 
FROM 
    sysobjects, 
    sysindexes 
WHERE 
    (sysobjects.xtype = 'U') AND (sysindexes.id = OBJECT_ID(sysobjects.name))
GROUP BY 
    sysobjects.name 
ORDER BY 
    2 DESC;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜