How to recover the deleted stored procedure?

If the stored procedure has been executed, you can try recovering it from the cache (lessons learned the hard way always seem to be the ones that stick with you).

​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 ;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s