Reputation: 867
Hi friends is there a query something like select * from [stored proc]
which returns execution plan of SQL statement in XML format...I don't want to use SSMS .
Upvotes: 1
Views: 685
Reputation: 138970
You can get the XML query plan by using sys.dm_exec_cached_plans and sys.dm_exec_text_query_plan.
select x.query_plan
from sys.dm_exec_cached_plans as p
cross apply sys.dm_exec_text_query_plan(p.plan_handle, 0, -1) as x
where p.objtype = 'proc' and
x.objectid = object_id('StoredProcName', 'P')
Upvotes: 1