richard mascarenhas (1/7/2012)
sp_updatestats only updates statistics that requires updating. hence, the ones that were rebuilt will be skipped.
If you run rebuild and update stats when nobody works with DB then it will be like you said, but if you have 24/7 system who will guarantee that nobody update at least one record between rebuild and sp_updatestats operations? And if such update happens then sp_updatestats will update your statistics with sample rate because based on rowmodctr that statistics requires updating. You can test it yourself:
CREATE DATABASE UpdateStatsTest
GO
USE UpdateStatsTest
CREATE TABLE dbo.T (ID int NOT NULL)
ALTER TABLE dbo.T ADD CONSTRAINT PK_T PRIMARY KEY CLUSTERED (ID )
INSERT dbo.T(ID) VALUES(1)
GO
ALTER INDEX [PK_T] ON [dbo].[T] REBUILD
INSERT dbo.T(ID) VALUES(2) -- Insert one record between rebuild and updatestats
EXEC sp_updatestats
Here is result, stats has been updated:
Updating [dbo].[T]
[PK_T] has been updated...
1 index(es)/statistic(s) have been updated, 0 did not require update.