Home Forums SQL Server 2008 T-SQL (SS2K8) get cached excution plan of single query out of procedure plan RE: get cached excution plan of single query out of procedure plan

  • Sure, you can pull from sys.dm_exec_text_query_plan. That requires a statement start offset and a statement end offset, both of which are available from sys.dm_exec_query_stats or sys.dm_exec_requests. It does return the query plan as text, so you have to throw a CAST AS XML on it if you want to be able to click on it in query results. Other than that, it's a great way to access plans as text and to get the isolated plan for a given statement.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning