SQL Flow Field Guide

SELECT - FOR clause

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

serializes the rowset into XML or JSON text/xml

What changes

Input
final ordered result rows
Output or change
one XML or JSON value (or browse-mode metadata)

Syntax at a glance

[ FOR { BROWSE | <XML> | <JSON> } ]

Work example

A client needs SQL Server to serialize a read-only rowset into a named XML or JSON shape.

Use synthetic rows with stable aliases. Parse the output and check how NULL values and nested names appear.

Check your work SELECT - FOR clause. The serialized document is valid and contains only the selected columns.

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