Home All Groups Group Topic Archive Search About

Table row counts different

Author
22 Jul 2005 6:16 PM
Andre
Can someone exlpain why you get different row counts in different places? 
For example, when I double-click on a table in EM to display the properties
of the table and look at the Rows number, that is different than when I query
like select count(*) from table.

Author
22 Jul 2005 6:21 PM
Barry
Andre,

I don't get any differences.
Are you sure the table hasn't been modified in between the 2 queries?

Barry
Author
22 Jul 2005 6:22 PM
Aaron Bertrand [SQL Server MVP]
SELECT COUNT(*) gets an actual, real-time count.

sp_spaceused and EM use a relatively "stale" count from sysindexes, which is
only updated periodically.

To make these more current, issue DBCC UPDATEUSAGE(0) which will update
sysindexes and EM for all tables in the database.  Or just use SELECT
COUNT(*)... (EM is not a reliable place for very many things).


Show quote
"Andre" <An***@discussions.microsoft.com> wrote in message
news:C7157969-A5C7-414A-8779-4E1CF26A5BDB@microsoft.com...
> Can someone exlpain why you get different row counts in different places?
> For example, when I double-click on a table in EM to display the
> properties
> of the table and look at the Rows number, that is different than when I
> query
> like select count(*) from table.
Author
22 Jul 2005 6:22 PM
Tibor Karaszi
EM picks up the row count from sysindexes, which is a very quick way to do it. But the value in
sysindexes might not be accurate (by design). See DBCC UPDATEUSAGE for more information.

Show quote
"Andre" <An***@discussions.microsoft.com> wrote in message
news:C7157969-A5C7-414A-8779-4E1CF26A5BDB@microsoft.com...
> Can someone exlpain why you get different row counts in different places?
> For example, when I double-click on a table in EM to display the properties
> of the table and look at the Rows number, that is different than when I query
> like select count(*) from table.

AddThis Social Bookmark Button