Last post Jun 12, 2019 01:56 PM by Saraqueen
Jun 12, 2019 10:45 AM|Saraqueen|LINK
Jun 12, 2019 10:55 AM|AddWeb Solution|LINK
The following SQL will get you the row count of all tables in a database:
CREATE TABLE #counts
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
The output will be a list of tables and their row counts.
Below are the highlights of this approach:
If you just want the total row count across the whole database, appending:
SELECT SUM(row_count) AS total_row_count FROM #counts
will get you a single value for the total number of rows in the whole database.
Please refer the below link
2 ) https://www.mssqltips.com/sqlservertip/2537/sql-server-row-count-for-all-tables-in-a-database/
I hope this will help you.
Jun 12, 2019 01:56 PM|Saraqueen|LINK