SQL Flow Field Guide

OPENXML

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

shreds XML into rows

What changes

Input
XML document handle (sp_xml_preparedocument), row pattern, flags
Output or change
rowset (edge table or WITH schema)

Syntax at a glance

OPENXML ( idoc int [ in ] , rowpattern nvarchar [ in ] , [ flags byte [ in ] ] ) [ WITH ( SchemaDeclaration | TableName ) ]

Work example

A legacy procedure exposes a prepared XML document as a rowset.

Check document handle ownership and cleanup. Review modern XML methods before extending the legacy path.

Check your work OPENXML. The expected rows are returned and the XML handle is released on success and error.

Open Microsoft Learn for full syntax, permissions, and details for your version.