Technical Article

Script to see Table Row Counts

,

Run the script.

This script gets the row counts in each table without doing a COUNT.

If you want to see # rows in a specific table you can add AND t.name LIKE '%TableName%' to the WHERE clause.

SELECT t.name [TableName], SUM(st.row_count)[RowCount]

FROM sys.tables t

JOIN sys.schemas s ON t.schema_id = s.schema_id

JOIN sys.indexes i ON t.object_id = i.object_id

JOIN sys.dm_db_partition_stats st ON t.object_id = st.object_id AND i.index_id = st.index_id

WHERE i.index_id < 2 

-- Heaps and Clustered IndexesGROUPBY s.name, t.name
GROUP BY t.name

ORDER BY  t.name;

Rate

4.8 (5)

You rated this post out of 5. Change rating

Share

Share

Rate

4.8 (5)

You rated this post out of 5. Change rating