UpdateStatisticsWith Method (Table) (SQL-DMO)

The UpdateStatisticsWith method forces data distribution statistics update for a indexes defined on the referenced Microsoft® SQL Server™ table.

Applies To

Table Object

Syntax

object.UpdateStatisticsWith( AffectType , ScanType , [ ScanNumber ]
, [ ReCompute ] )

Part Description
object Expression that evaluates to an object in the Applies To list.
AffectType Long integer specifying an statistics source as described in Settings.
ScanType Long integer specifying a data sampling method as described in Settings.
ScanNumber Optional. A long integer indicating a sample size as described in Settings.
ReCompute Optional. When True (default), no change is made to automatic update of data distribution statistics. When False, automatic update of data distribution statistics is disabled.

Settings

Set AffectType by using these values.

Constant Value Description
SQLDMOStatistic_AffectAll 2 Update all statistics regardless of the source.
SQLDMOStatistic_AffectColumn 1 Update statistics derived from column data only.
SQLDMOStatistic_AffectIndex 0 Default. Update statistics derived from indexes only.

Set ScanType by using these values. When a ScanType setting indicates a sample size, set ScanNumber as described.

Constant Value Description
SQLDMOStatistic_FullScan 3 Perform a full scan of the index(es) or column(s) to determine statistics values.
SQLDMOStatistic_Percent 1 Perform a sampled scan using a percentage value. When specified, use the ScanNumber value to indicate percentage. Specify percentage using a whole number, for example, 55 specifies 55 percent.
SQLDMOStatistic_Rows 2 Perform a sampled scan using a number of rows. When specified, use the ScanNumber argument to indicate number of rows.
SQLDMOStatistic_Sample 0 Perform a percentage sampled scan using a system defined percentage.

Remarks

Index-based, data distribution statistics support SQL Server query optimization. Data distribution statistics are calculated for an index when the index is first used in query optimization or at user direction. Statistics are updated automatically at configurable intervals and at user direction. The UpdateStatisticsWith method directs statistic update, optionally restricting statistics sampling to optimize the process.

Prototype (C/C++)

HRESULT UpdateStatisticsWith(
SQLDMO_STAT_AFFECT_TYPE AffectType,
SQLDMO_STAT_SCAN_TYPE ScanType,
long ScanNumber CPPDEFAULT(=0),
BOOL ReCompute CPPDEFAULT(=TRUE);


(c) 1988-98 Microsoft Corporation. All Rights Reserved.