sql-server ,

Fetch Row Count for All Tables in a SQL SERVER

Abhith Rajan Abhith Rajan FollowMarch 11, 2018 · 1 min read · Last Updated:
Share this

Just execute the below query in the database to see the list of tables and number of records in each table.

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 s.index_id IN (0,1)
Abhith Rajan
Written by Abhith Rajan FollowBuy me a coffee
Abhith Rajan is an aspiring software engineer with more than 6 years of experience and proven successful track record of delivering technology-based products and services.