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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How many records in each table?

Author  Topic 

gokhan
Starting Member

3 Posts

Posted - 2006-05-11 : 07:33:34
I have 97 tables in my database. I want to print table name plus the number of records of this table. Format is like:
************************
table name records
---------- -------
table1 3
table2 5
table3 0
..
..
table97 0
************************
What is the easiest way of this?
Thanks...

Kristen
Test

22859 Posts

Posted - 2006-05-11 : 07:35:59
http://www.databasejournal.com/scripts/print.php/1450801 perhaps?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-11 : 07:52:33
After you run DBCC UpdateUsage command try

Select object_name(id) as table_name, rows
from sysindexes where indid<2 order by 1


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

gokhan
Starting Member

3 Posts

Posted - 2006-05-11 : 07:54:37
working perfect! thank you very much Kristen...
Go to Top of Page

gokhan
Starting Member

3 Posts

Posted - 2006-05-11 : 08:09:08
quote:
Originally posted by madhivanan

After you run DBCC UpdateUsage command try

Select object_name(id) as table_name, rows
from sysindexes where indid<2 order by 1


Madhivanan

Failing to plan is Planning to fail



Thank you very much madhivanan, simple and works great!
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-05-11 : 08:14:49
You ought to run DBCC UpdateUsage before using the code in the link I provided too - as I don't think it is included, and without it the figures may be a little stale.

Kristen
Go to Top of Page
   

- Advertisement -