Get the number of records for each table in a DB

Created by
Tuesday, August 16, 2016

List of tables with a sum of the number of records.

 

CREATE TABLE #Tab   
(  
	Table_Name [varchar](max),  
	Total_Records int  
);  
  
EXEC sp_MSForEachTable @command1=' Insert Into #Tab(Table_Name, Total_Records) SELECT ''?'', COUNT(*) FROM ?'  
  
SELECT * FROM #Tab t ORDER BY t.Total_Records DESC;  
  
DROP TABLE #Tab;  

 

0
Rating
1 2 3 4 5

Save

Saved

Report

Reported
Reasons
Cancel
0 comments