January 30, 2013 at 7:22 am
Hi,
I want to check how long an SP executed. The last last execution time was 2 hrs ago. Can any one help me in finding the query?
January 30, 2013 at 7:45 am
Query the Plan Cache using sys.dm_exec_query_stats. There is a column called "last_execution_time".
______________________________
AJ Mendo | @SQLAJ
January 30, 2013 at 7:50 am
It gives the last execution time. But how to find out the start & end time?
January 30, 2013 at 7:52 am
To look for it within a 1 hour window, 2 hours ago - and assuming you know the procedure name:
select qs.last_execution_time, qs.last_elapsed_time, st.text
from sys.dm_exec_query_stats qs
cross apply sys.dm_exec_sql_text(qs.sql_handle) st
where last_execution_time between dateadd(minute, -150, getdate()) and dateadd(minute, -90, getdate())
and st.text like '%YourProcNameHere%'
January 30, 2013 at 8:12 am
Is "last_elapsed_time" = total execution time of the SP?
January 30, 2013 at 8:27 am
Yes. It is the total amount of time it took to execute, in microseconds.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply