SQL Flow Field Guide

SET STATISTICS XML

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

adds an actual XML plan result set

What changes

Input
none
Output or change
session state

Syntax at a glance

SET STATISTICS XML { ON | OFF }

Work example

A tuning review needs the measurement supplied by SET STATISTICS XML for one read-only query.

Capture a baseline and run the same query and parameters before and after a single change. Turn the setting off when the capture ends.

Check your work SET STATISTICS XML. The SET STATISTICS XML output is tied to the measured query and the setting is off for the next user of the session.

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