SQL Flow Field Guide

ALTER TABLE ... REBUILD

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

rebuilds the heap or clustered index

What changes

Input
all rows of the table or partition
Output or change
rewritten storage

Syntax at a glance

ALTER TABLE table REBUILD [ PARTITION = { ALL | n } ] [ WITH ( <rebuild_option> [ ,...n ] ) ]

Work example

A table rebuild is proposed to apply a measured physical or compression change.

Estimate space, log, locks, availability, and index effects on a representative copy.

Check your work The rebuild meets the maintenance window and preserves row counts and constraints.

Open Microsoft Learn for full syntax, permissions, and details for your version.