ALTER TABLE ... REBUILD
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.