﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / get cached excution plan of single query out of procedure plan / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 12:37:21 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: get cached excution plan of single query out of procedure plan</title><link>http://www.sqlservercentral.com/Forums/Topic1417655-392-1.aspx</link><description>Thank you, exactly what I was looking for :-)</description><pubDate>Fri, 08 Feb 2013 08:22:42 GMT</pubDate><dc:creator>WolfgangE</dc:creator></item><item><title>RE: get cached excution plan of single query out of procedure plan</title><link>http://www.sqlservercentral.com/Forums/Topic1417655-392-1.aspx</link><description>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.</description><pubDate>Fri, 08 Feb 2013 08:05:05 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>get cached excution plan of single query out of procedure plan</title><link>http://www.sqlservercentral.com/Forums/Topic1417655-392-1.aspx</link><description>Hello there,when analyzing a procedure I often query the cached execution plans of procedures. I use this (simplified) query:[code="sql"]select	querytext.objectid,	querystat.plan_handle,	QueryText = substring( querytext.text, querystat.statement_start_offset/2+1, ( querystat.statement_end_offset - querystat.statement_start_offset )/2 + 1 ),	queryplan.query_planfrom sys.dm_exec_query_stats querystat	cross apply sys.dm_exec_sql_text( querystat.sql_handle ) as querytext	cross apply sys.dm_exec_query_plan( querystat.plan_handle ) as queryplanwhere querytext.dbid = db_id()	and querytext.objectid = Object_id( 'dbo.SomeProcedure')[/code]Unfortunately I get the execution plan only for the whole procedure. As I can query the text of each single statement I'd like to have the execution plan of each single statement too. This would be much more conventient as for procedures containing many statements it's often difficult to find the query within the large execution plan.Is there any possibility?I know I could use the SQL Profiler to get each single query whith it's single execution plan. As the profiler is not always running I'd like to query it from the procedure cache.Thank you, Wolf</description><pubDate>Fri, 08 Feb 2013 06:13:39 GMT</pubDate><dc:creator>WolfgangE</dc:creator></item></channel></rss>