delete (XML DML)
XML DML delete (inside modify())
What changes
- Input
- XPath target nodes
- Output or change
- the xml instance being modified
Syntax at a glance
delete Expression
Work example
Remove one matching element or attribute from an XML value.
Use a predicate that identifies the intended node and test the path against zero, one, and several matches.
Check your work Deleting a selected node can also remove its nested content.
Practice SQL
Open in SQL FlowDECLARE @doc xml = N'<Order><Item code="A1" /><Item code="B2" /></Order>'; SET @doc.modify('delete (/Order/Item[@code="A1"])[1]'); SELECT @doc AS updated_xml;
Open Microsoft Learn for full syntax, permissions, and details for your version.