✅ Transact-SQL Syntax:
When you do not specify an index or a statistics, all statistics are updated.
✅ Explanation (Rewritten for SQL Server 2022)
🔹 `WITH` Clause Options
UPDATE STATISTICS table_name [ ( statistics_name [ ,...n ] ) | index_name ] [ WITH [ FULLSCAN | SAMPLE number { PERCENT | ROWS } ] [ , { ALL | COLUMNS | INDEX } ] [ , NORECOMPUTE ] ]
When you do not specify an index or a statistics, all statistics are updated.
✅ Explanation (Rewritten for SQL Server 2022)
🔹 `WITH` Clause Options
Option | SQL Server 2022 Description |
---|---|
FULLSCAN |
Updates statistics using all rows in the table — provides maximum accuracy. |
SAMPLE number PERCENT |
Samples a percentage of rows. Improves performance when a full scan is unnecessary. |
SAMPLE number ROWS |
Samples a fixed number of rows. Useful for very large tables. |
ALL |
Updates all statistics: both index-based and column-based. |
COLUMNS |
Updates only column-level statistics (non-indexed). |
INDEX |
Updates only statistics associated with indexes. |
NORECOMPUTE |
Prevents SQL Server from automatically updating the specified statistics in the future. |
There is a core, built-in feature of the SQL Server Query Optimizer.
This automatic process is controlled by a database setting called `AUTO_UPDATE_STATISTICS`. When this option is turned on (which it is by default), the Query Optimizer automatically detects when statistics are "stale" or out-of-date and updates them before compiling a query.
The "Intelligent Threshold"
The logic that determines when statistics are stale has become more intelligent over time.
The next lesson will show you how to view statistics information.

The "Intelligent Threshold"
The logic that determines when statistics are stale has become more intelligent over time.
- Legacy Threshold: It used to be a simple rule where statistics were updated after about 20% of the rows in a table had been modified. This was inefficient for very large tables, as it could take millions of changes to trigger an update.
- Modern Threshold: Since SQL Server 2016 (and available in earlier versions via Trace Flag 2371), the threshold is dynamic and more intelligent. It lowers as a table gets larger. This means a smaller percentage of row changes will trigger an update on a massive table, ensuring the statistics are kept up-to-date more effectively. This modern threshold is based on a formula that uses the square root of the number of table rows: `sqrt(1000 * table_rows)`.
Best Practices for SQL Server 2022
- Use
FULLSCAN
for critical reports or predictable performance. - Use
SAMPLE
options for large tables where speed is preferred over precision. - Avoid
NORECOMPUTE
unless you have a strong reason — modern statistics auto-updating is intelligent and generally recommended.
The next lesson will show you how to view statistics information.