TSQL query to find un-used stored procedures

后端 未结 3 863
时光取名叫无心
时光取名叫无心 2020-12-29 06:29

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

3条回答
  •  伪装坚强ぢ
    2020-12-29 06:57

    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.

提交回复
热议问题