I am trying to track down all stored procedures in a database that have never been used, or that have not been used in many months.
I would like to find a query to s
Here's a variation on the accepted answer that was the most useful for me:
SELECT sc.NAME + '.' + p.NAME [Procedure]
,s.last_execution_time
FROM sys.procedures AS p
LEFT JOIN sys.dm_exec_procedure_stats AS s ON p.[object_id] = s.[object_id]
INNER JOIN sys.schemas sc ON p.schema_id = sc.schema_id
ORDER BY s.last_execution_time
,sc.NAME
,p.NAME
The modifications display the last execution time and include the procedure's schema.