如何查看SQL Server某个存储过程的执行历史【转】
SELECT TOP 100 db_name(d.database_id) as DBName, s.name as 存储名称, s.type_desc as 存储类型, d.cached_time as SP添加到缓存的时间, d.last_execution_time as 上次执行SP的时间, d.last_elapsed_time as [上次执行SP所用的时间(微妙)], d.total_elapsed_time as [完成此SP的执行所用的总时间(微妙)], d.total_elapsed_time/d.execution_count as [平均执行时间(微妙)], d.execution_count as 自上次编译以来所执行的次数 FROM SYS.procedures S JOIN SYS.dm_exec_procedure_stats D ON S.object_id=D.object_id WHERE S.NAME='SP_Name' ORDER BY D.total_elapsed_time/D.execution_count DESC