SQL Server - All tables row count

30 January,2010 by Jack Vamvas

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

 Related Posts

SQL Server Disable Indexes and Rebuild Indexes dynamically

SQL Index Fragmentation and sys.dm_db_index_physical_stats

SQL Server sp_updatestats and UPDATE STATISTICS


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on SQL Server - All tables row count


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer