On Sql Server 2000, is there a way to find out the date and time when a stored procedure was last executed?
在Sql Server 2000上,有没有办法找出上次执行存储过程的日期和时间?
2 个解决方案
#1
8
Not without logging or tracing, I'm afraid
我很害怕,不是没有记录或追踪
#2
23
If a stored procedure is still in the procedure cache, you can find the last time it was executed by querying the sys.dm_exec_query_stats DMV. In this example, I also cross apply to the sys.dm_exec_query_plan DMF in order to qualify the object id:
如果存储过程仍在过程高速缓存中,则可以通过查询sys.dm_exec_query_stats DMV来查找上次执行该过程。在这个例子中,我还交叉应用于sys.dm_exec_query_plan DMF以限定对象id:
declare @proc_nm sysname
-- select the procedure name here
set @proc_nm = 'usp_test'
select s.last_execution_time
from sys.dm_exec_query_stats s
cross apply sys.dm_exec_query_plan (s.plan_handle) p
where object_name(p.objectid, db_id('AdventureWorks')) = @proc_nm
[资源]
#1
8
Not without logging or tracing, I'm afraid
我很害怕,不是没有记录或追踪
#2
23
If a stored procedure is still in the procedure cache, you can find the last time it was executed by querying the sys.dm_exec_query_stats DMV. In this example, I also cross apply to the sys.dm_exec_query_plan DMF in order to qualify the object id:
如果存储过程仍在过程高速缓存中,则可以通过查询sys.dm_exec_query_stats DMV来查找上次执行该过程。在这个例子中,我还交叉应用于sys.dm_exec_query_plan DMF以限定对象id:
declare @proc_nm sysname
-- select the procedure name here
set @proc_nm = 'usp_test'
select s.last_execution_time
from sys.dm_exec_query_stats s
cross apply sys.dm_exec_query_plan (s.plan_handle) p
where object_name(p.objectid, db_id('AdventureWorks')) = @proc_nm
[资源]