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
 SQL Server Administration (2000)
 List all tables and row count WITH owner name

Author  Topic 

itsonlyme4
Posting Yak Master

109 Posts

Posted - 2009-05-05 : 10:47:47
MS SQL Server 2000 - used this to list all tables and their row counts for a Database.

select distinct convert(varchar(30),object_name(a.id)) [Table Name], a.rows from sysindexes a inner join sysobjects b on a.id = b.id 


Can anyone tell me please how to modify this so that it also returns the DB owner for each table?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2009-05-05 : 10:53:25
[code]
select distinct convert(varchar(30),object_name(a.id)) [Table Name], a.rows , su.name
from sysindexes a
inner join sysobjects b on a.id = b.id
join sysusers su on b.uid = su.uid
[/code]

I would NOT rely on rowcount from indexes in SQL 2000 to get the count of rows. It is not alays up to date. Depending on what this information is used for I would do a SELECT COUNT(*) and use sp_MSforeachtable (etc).. instead

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

itsonlyme4
Posting Yak Master

109 Posts

Posted - 2009-05-05 : 11:00:48
At this point, it is not important that the row counts are 100% accurate - but I will take that into consideration. Thank you for your help!!!!
Go to Top of Page
   

- Advertisement -