如何查看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
相關文章
相關標籤/搜索