SQL Flow Field Guide

QUERY HINT USE PLAN N'xml_plan'

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

Forces the Query Optimizer to use an existing query plan for a query specified by xml_plan.

What changes

Input
none
Output or change
none

Syntax at a glance

OPTION ( USE PLAN N'xml_plan' )

Work example

A measured plan issue may justify investigating QUERY HINT USE PLAN N'xml_plan' for one known query shape.

Save the actual plan and runtime metrics first. Test representative parameter values and remove the hint if the plan no longer fits.

Check your work QUERY HINT USE PLAN N'xml_plan'. The plan property affected by QUERY HINT USE PLAN N'xml_plan' changes as intended and reads, duration, and result rows remain acceptable.

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