Total row counts of all tables in a Sql Server database

Sometimes you may want to know the total row counts of all tables in a database. The script below will give you a rough idea. However, it is not guaranteed to be accurate, though. It works in both Sql Server 2000 and Sql Server 2005.

select sum(rowcnt) from sysindexes inner join sysobjects on sysindexes.id=sysobjects.id where sysobjects.xtype = ‘U’
and sysobjects.name not in (‘dtproperties’)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.