Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: 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.


advertisement

WEBINAR:

On-Demand

Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js


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;

 

Visit the DevX Tip Bank

 





   
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date