简体   繁体   中英

Query to result execution plan in SQL Server 2008 out of SSMS

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.

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM