存储过程上次执行日期SQL

时间:2016-08-31 16:43:08

标签: sql-server-2014

我正在创建一个新的存储过程。有没有办法找出我的存储过程的最后一次执行?每次我执行它? SQL Server 2014

1 个答案:

答案 0 :(得分:2)

You can use the sys.dm_exec_procedure_stats system view to find out the last time your sp was executed:

SELECT  b.name, 
        a.last_execution_time
FROM sys.dm_exec_procedure_stats a 
INNER JOIN sys.objects b 
    ON a.object_id = b.object_id 
WHERE DB_NAME(a.database_ID) = 'YourDatabase'
AND b.name = 'YourSp';