Skip to content

Instantly share code, notes, and snippets.

@ChauThan
Created November 11, 2013 07:36
Show Gist options
  • Save ChauThan/7409306 to your computer and use it in GitHub Desktop.
Save ChauThan/7409306 to your computer and use it in GitHub Desktop.
Get last execution of store procedured
SELECT CASE PS.database_id
WHEN 32767
THEN 'Resource DB'
ELSE DB_NAME(PS.database_id)
END AS [DB Name]
,OBJECT_NAME(PS.object_id, PS.database_id) AS [SP Name]
,PS.last_execution_time AS [Last Executed]
,PS.execution_count AS [# runs]
FROM sys.dm_exec_procedure_stats PS
ORDER BY DB_NAME(PS.database_id)
,PS.last_execution_time DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment