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
 General SQL Server Forums
 New to SQL Server Programming
 Number of rows in a table

Author  Topic 

kiruthika
Yak Posting Veteran

67 Posts

Posted - 2007-11-18 : 23:31:56
HI!
1.select count(*) from sales
2.select rows from sysindexes where id=object_id('sales') and indid<2

both queries return number of rows.
can anyone tell me which one is better?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-19 : 01:47:09
Method 1 is always reliable
In order to get accurate count you need to run DBCC Updateusage('dbname','tablename') with count_rows before running method 2

Madhivanan

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

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-11-19 : 11:59:51
Better How?

Method one as Madhivanan said is accurate. Where as Method two is less resource intensive, but may not be 100% accurate.
Go to Top of Page
   

- Advertisement -