CREATE XML INDEX
defines an index; CREATE/ALTER REBUILD sorts and writes all rows of the key
What changes
- Input
- table or view columns (key, included, filter predicate)
- Output or change
- index structure (B-tree, columnstore, XML, spatial, JSON, vector, full-text)
Syntax at a glance
CREATE [ PRIMARY ] XML INDEX index_name ON <object> ( xml_column_name ) [ USING XML INDEX xml_index_name [ FOR { VALUE | PATH | PROPERTY } ] ] [ WITH ( <xml_index_option> [ ,...n ] ) ] [ ; ]
Work example
An XML query workload needs a primary or secondary XML index.
Match the index kind to the XQuery pattern and include the required primary index dependency.
Check your work A representative XQuery returns the same rows and the plan uses the intended XML index.
Open Microsoft Learn for full syntax, permissions, and details for your version.