SQLUSA

Microsoft SQL Server 2000 Best Practices

How to obtain quick counts of rows in all tables?

 

The following will quickly list approximate rowcounts for all the tables in the database:

use DatabaseName

select TableName = o.name, Rows = max(i.rows)
from sysobjects o
join sysindexes i
on o.id = i.id
where xtype='u'
and OBJECTPROPERTY(o.id, N'IsUserTable') = 1
group by o.name
order by TableName

 

 

American Standard in SQL Server Training
 
SQLUSA.com Home Page