×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Get the Total Number of Rows for Each Table in Your Database
 

Submitted by: Hannes du Preez(ojdupreez1978@gmail.com)

Thursday Jan 18th 2018 by Hannes du Preez

Language: SQL, Level: Beginner: - Use the following query to get the total number of rows for each table in your database

Use the following query to get the total number of rows for each table in your database:

CREATE TABLE #TempTable  
(  
[Table Name] [varchar](max),  
  
[Total Records] int  

);  
  
EXEC sp_MSForEachTable @command1 = ' Insert Into #Tab(Table_Name, Total_Records) SELECT ''?'', COUNT(*) FROM ?'  
  
SELECT * FROM #TempTable t ORDER BY t.[Total Records] DESC;  
  
DROP TABLE #TempTable;
Home
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved