Thursday, February 27, 2014

when did last time a stored procedure executed?

SELECT    Database_id,
        OBJECT_NAME(object_id, Database_id) AS 'ProcedureName',
        Cached_Time,
        Last_Execution_Time,
        Total_Elapsed_Time,
        Total_Elapsed_Time/Execution_Count AS Avg_Elapsed_Time,
        Last_Elapsed_Time, Execution_Count
FROM sys.dm_exec_procedure_stats
WHERE --DB_Name(database_Id)= 'YourDB'  and -- your database ID
OBJECT_NAME(object_id, Database_id) = 'Your ProcedureName'
ORDER BY [Total_Worker_Time] DESC;

No comments:

Post a Comment