You are here:Home » tsql » Find Last Access Date of Stored Procedures, Views and Triggers.

Find Last Access Date of Stored Procedures, Views and Triggers.

select distinct db_name(eqp.dbid) as [DBName],
object_name(eqp.objectid, dbid) as [ProcedureName],
eqs.last_execution_time
from sys.dm_exec_cached_plans ecp
join sys.dm_exec_query_stats eqs on ecp.plan_handle = eqs.plan_handle
cross apply sys.dm_exec_query_plan(ecp.plan_handle) eqp
where objtype = N'Proc'