How Can We Help?

Get the count of records in all tables of a database

You are here:
← All Topics

table_name varchar(255),
row_count int

EXEC sp_MSForEachTable @command1=’INSERT #counts (table_name, row_count) SELECT ”?”, COUNT(*) FROM ?’
SELECT table_name, row_count FROM #counts ORDER BY table_name, row_count DESC
DROP TABLE #counts

Next Get the List of all the queries executed on a Particular SQL Database
Table of Contents