Hi Gurus
I am trying to capture an execution plan form the query cache using the T-SQL
SELECT cp.objtype AS ObjectType, OBJECT_NAME(st.objectid,st.dbid) AS ObjectName, cp.usecounts AS ExecutionCount, st.TEXT AS QueryText, qp.query_plan AS QueryPlan FROM sys.dm_exec_cached_plans AS cp CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) AS st WHERE st.TEXT like '%TtestTable%
I get the results like the below but when I click on the execution plan it just comes up with SELECT block 0%.. .
I tried to change the setting in SSMS or XML form 2 MB to unlimited etc..still doesn't resolve my question.
Why I need execution plan form cache?
Its because I just want to see the query execution plan inside the sql engine rather me capturing the actual execution plan as it may be different due parameter sniffing etc..
Kind Regards,
Chinna.