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 2005 Forums
 SQL Server Administration (2005)
 When Sys.parttition,sys.indexes gets Updated

Author  Topic 

pradeep_iete
Yak Posting Veteran

84 Posts

Posted - 2010-01-15 : 07:14:10
Hi All,

Guys Can u all tell me when difference between following queries exist then how to update it in system.catalogues


Query1)

SELECT count(*) FROM <table>
Query2)

SELECT rowcnt FROM sys.indexes WHERE Object_ID=OBJECT_ID(<TABLE>)
OR
SELECT * FROM sys.partitions WHERE Object_ID=OBJECT_ID(<TABLE>)


I have found difference between the two queries all the time ?WHY it is SO?
How we can update the deficit therefore ?

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2010-01-15 : 08:07:57
count * counts every record (subject to the where clause)
count somecol only counts records with somecol notnull (ditto)
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-01-15 : 10:15:13
DBCC UpdateUsage

Shouldn't be needed on SQL 2005, but if this DB was upgraded from SQL 2000, there could still be discrepancies.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -