SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 When Sys.parttition,sys.indexes gets Updated
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pradeep_iete
Yak Posting Veteran

India
84 Posts

Posted - 01/15/2010 :  07:14:10  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Ireland
2916 Posts

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

GilaMonster
Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 01/15/2010 :  10:15:13  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.56 seconds. Powered By: Snitz Forums 2000