Count(*) and Sp_spaceused | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Count(*) and Sp_spaceused

Why does Count(*) and sp_spaceused rows count is different for some tables? I used Dbcc updatausage to corrects pages and row count inaccuracies , still i see the difference. How could i make it even? Thanks
emamuthu
Got it, When i used Dbcc updateusage with Count_rows it works. Thanks
emamuthu
BOL: sp_spaceused [[ @objname = ] ‘objname’ ]
[,[ @updateusage = ] ‘updateusage’ ] exec sp_spaceused @updateusage = ‘updateusage’
MohammedU.
Moderator
SQL-Server-Performance.com All postings are provided “AS IS” with no warranties for accuracy.

What it does is to update the mismatached rows with sysindexes and sysbjects. Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. The greatest discovery of my generation is that a human being can alter his life by altering his attitudes of mind.
In any case, the rowcount returned by sp_spaceused isn’t guranteed to always match the *exact* real rowcount, at any given time. If an absolute rowcount is necessary (within the isolation level), then
SELECT COUNT(*) FROM myTable is the only accurate method. Hence there may be differences from time to time between sp_spaceused and select count(*) /Kenneth
thanks for reply. Emamuthu
]]>