Sometimes there is a requirement to report on total sql row count of all tables. Useful code to gather the SQL row count of all SQL Server tables in a database. The process could be quicker quicker if you reindex prior to executing this code.
This query is dependant on views with SQL Server 2000 backward compatability.
SELECT SCHEMA_NAME(t1.schema_id) AS [schema], t1.name AS [table], i1.rows AS [row_count] FROM sys.tables AS t1 INNER JOIN sys.sysindexes AS i1 ON t1.object_id = i1.id AND i1.indid < 2
Author: Jack Vamvas
Leave a Reply