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 TableRowsYou can find the original here.
FROM sysindexes INNER JOIN sysobjects ON sysindexes.[id] = sysobjects.[id]
WHERE sysobjects.xtype = 'U'
GROUP BY sysobjects.[name]
ORDER BY name
0 Responses to "How many rows in all the tables in a database?":
Post a Comment