Easy way to fetch row count for all tables in a SQL database

This is just a quick post for, with a old method for fetching the row count for a entire database – for future reference (Works in Azure – doesn’t require stored proc)

SELECT t.name, s.row_count from sys.tables t
JOIN sys.dm_db_partition_stats s
ON t.object_id = s.object_id
AND t.type_desc = 'USER_TABLE'
AND t.name not like '%dss%'
AND s.index_id IN (0,1)
order by s.row_count desc

You may also like...

Leave a Reply

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