Home > Last Execution Date for Stored Procedure > How to find Last Execution Date of Stored Procedure

How to find Last Execution Date of Stored Procedure

I have seens this common question on few SQL Server Forum that how can i get the last execution date for Stored Procedur or when was the stored procedure exedcuted last.

Now How to achive this?

Every SQL Stament sent to SQL Server is PARSED,COMPILEd and EXECTED.SQL Server maintains QUERY PLAN for each and every statement and keeps it in the system tables.

Which we can query using DMV’s.Query Plans are flushed out if SQL Server Service gets started manulally or automatically(In cluster mode)/runs update stats command / reindexing / usinf DBCC CACHE Clean Commands.

To get last execution date of the stored procedure if SQL Server has the Query Plan for it.

SELECT qs.sql_handle,qs.statement_start_offset,qs.statement_end_offset,

FROMsys.dm_exec_query_statsAS qs
CROSSAPPLYsys.dm_exec_sql_text(qs.sql_handle)AS st
CROSSAPPLYsys.dm_exec_text_query_plan(qs.plan_handle,DEFAULT,DEFAULT)AS qp
WHERE st.textlike‘%USP_CDS_GetUserDetails%’


  1. Santhosh
    February 17, 2012 at 12:31 pm

    The execution time column does not show the last time when the proc is executed, it is showing the current datetime. May be you selected wrong column??

    • msufian
      November 29, 2012 at 8:08 am

      If you are seeing the current date , it means that SP has been executed on that date

  1. No trackbacks yet.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: