ALTER TABLE ... SWITCH
moves a whole partition between tables
What changes
- Input
- all rows of a source table or partition
- Output or change
- target table or partition (metadata move, no row copy)
Syntax at a glance
ALTER TABLE source SWITCH [ PARTITION n ] TO target [ PARTITION m ]
Work example
A partitioned table needs a metadata switch for a controlled load or archive.
Compare source and target columns, indexes, constraints, filegroups, and partition boundaries before switching.
Check your work The source partition is empty after the switch and all expected rows appear in the target.
Open Microsoft Learn for full syntax, permissions, and details for your version.