DECLARE @spid AS INT;
SET @spid = 86; -- UPDATE VARIABLE SPID ID
SELECT session.session_id, sql_text.text as most_recent_requested_query, plan_text.query_plan
FROM sys.dm_exec_sessions as session WITH (NOLOCK)
LEFT OUTER JOIN sys.dm_exec_requests as request WITH (NOLOCK) ON session.session_id = request.session_id
OUTER APPLY sys.dm_exec_sql_text(request.s ql_handle) as sql_text
OUTER APPLY sys.dm_exec_query_plan(request .plan_handle) as plan_text
WHERE session.session_id = @spid;
If for some reason when you click on the XML it simply bring up the XML in a new query window you can save the xml in a file with the extension .sqlplan and then open the file. SSMS should then display the graphical plan.
No comments:
Post a Comment