Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2011-07-29 : 04:51:46
|
Hi Team,i have a requirement like i need to get all the tables in a table, and row count of each table. is there any script for that? can you kindly suggest me in this? there are lot many tables, else i can use below one likeselect * from information_schema.tablesandselect count(*) from <all tables one by one>please help me to get all tables with number of rows in each table in a single shot.thanks in advanceArnavEven you learn 1%, Learn it with 100% confidence. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-07-29 : 05:20:49
|
you need to create a cursor based script for looping through INFORMATION_SCHEMA.TABLES catalog view and then use dynamic sql for getting counts from each table.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
gwilson67
Starting Member
42 Posts |
Posted - 2011-08-29 : 00:53:24
|
Hi, here's a query from my code repository that I'll share with you. it doesn't need a cursor.select st.name, si.rows from sys.tables st inner join sysindexes si on st.object_id=si.id where si.indid<2Greghttp://www.freewebstore.org/tsqlcoderepositoryPowerful tool for SQL Server development |
 |
|
|
|
|