Quite often , this question appears on forums or on various jobs."Is there any way that I can tell when a stored procedure was last executed or who executed it? Is there any execution history that I can look at?"
The following query will assist in telling you what time a stored procedure was last executed – assuming the query hasn’t been flushed from the cache.
SELECT object_name(m.object_id), MAX(qs.last_execution_time)
FROM sys.sql_modules m
LEFT JOIN (sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text (qs.sql_handle) st)
ON m.object_id = st.objectid
AND st.dbid = db_id()
GROUP BY object_name(m.object_id);
Ref:Jack Vamvas (http://www.sqlserver-dba.com)
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |