How many rows in all the tables in a database?

Posted on Thursday, July 16, 2009 by Nicki

Often one needs to know the number of rows in all tables in a database, like when you are writing or executing tests, and need to know if you have test data for a table.


I found a nice query, and adapted it slightly for my use.
SELECT sysobjects.[name], max(sysindexes.[rows]) AS TableRows
FROM sysindexes INNER JOIN sysobjects ON sysindexes.[id] = sysobjects.[id]
WHERE sysobjects.xtype = 'U'
GROUP BY sysobjects.[name]
ORDER BY name
You can find the original here.

0 Responses to "How many rows in all the tables in a database?":