MS SQL Tips & Tricks

How to get number of records in each table in database

To get record rumber from all tables in database You just need to execute script bellow:

SELECT as TableName, 
	max(sysindexes.rows) AS TableRows
FROM sysindexes INNER JOIN sysobjects ON =
WHERE sysobjects.xtype = 'U'
ORDER BY max(sysindexes.rows) DESC

There is an assumption made, that each table has at least one index created.

Learn more tricks

Add Comment