Friday 25 January 2013

Recover your Store Procedure from Cache


If the stored procedure has been executed, you can try recoving if from the cache with help of following query.

SELECT [cp].[refcounts],
               [cp].[usecounts],[cp].[objtype],
               [st].[dbid], [st].[objectid], [st].[text], [qp].[query_plan]
FROM sys.dm_exec_cached_plans cp 
CROSS APPLY sys.dm_exec_sql_text ( cp.plan_handle ) st
CROSS APPLY sys.dm_exec_query_plan ( cp.plan_handle ) qp

No comments:

Post a Comment