SQL Server Get Row Count of All Tables
Get all the tables with a count of their records with the following query:
CREATE TABLE #Temp ( TableName VARCHAR(MAX), Rows INT ); EXEC sp_MSForEachTable @command1 = 'INSERT INTO #Temp(TableName, Rows) SELECT ''?'', COUNT(*) FROM ?' SELECT * FROM #Temp ORDER BY Rows DESC; DROP TABLE #Temp;
source: https://www.sswug.org/sswugresearch/community/get-all-the-tables-with-a-count-of-their-records/?preview_id=268538