May 2019
Intermediate to advanced
484 pages
11h 23m
English
In the Query plan properties of interest section of Chapter 4, Exploring Query Execution Plans, we covered warnings that can occur in a query execution plan at either the plan level or the operator level. We can leverage XQueries to identify plans with warnings as well.
The following query will find query execution plans that have a plan-level warning:
WITH XMLNAMESPACES(DEFAULT'http://schemas.microsoft.com/sqlserver/2004/07/showplan'), WarningSearch AS (SELECT qp.query_plan, cp.usecounts, cp.objtype, wn.query('.') AS StmtSimple, cp.plan_handle FROM sys.dm_exec_cached_plans cp WITH (NOLOCK) CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) qp CROSS APPLY qp.query_plan.nodes('//StmtSimple') AS p(wn) WHERE wn.exist('//Warnings') ...Read now
Unlock full access