SQL Flow Field Guide

delete (XML DML)

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

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 Flow
DECLARE @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.