sys.dm_exec_procedure_stats contains information about the execution functions, restrictions and procedures, etc. But the row has a life span. When the execution plan is deleted from the cache, the entry will disappear.
Use [yourDatabaseName] GO SELECT SCHEMA_NAME(sysobject.schema_id), OBJECT_NAME(stats.object_id), stats.last_execution_time FROM sys.dm_exec_procedure_stats stats INNER JOIN sys.objects sysobject ON sysobject.object_id = stats.object_id WHERE sysobject.type = 'P' ORDER BY stats.last_execution_time DESC
This will give you a list of recently completed procedures.
If you want to check if a recently executed stored procedure was running
SELECT SCHEMA_NAME(sysobject.schema_id), OBJECT_NAME(stats.object_id), stats.last_execution_time FROM sys.dm_exec_procedure_stats stats INNER JOIN sys.objects sysobject ON sysobject.object_id = stats.object_id WHERE sysobject.type = 'P' and (sysobject.object_id = object_id('schemaname.procedurename') OR sysobject.name = 'procedurename') ORDER BY stats.last_execution_time DESC
Naruto Apr 04 '17 at 8:43 on 2017-04-04 08:43
source share