如何查看 SQL Server 执行的历史 SQL 语句记录?

1 SELECT st.text as sql_statement,
2        qs.creation_time as plan_last_compiled,
3        qs.last_execution_time as plan_last_executed,
4        qs.execution_count as plan_executed_count,
5        qp.query_plan
6 FROM sys.dm_exec_query_stats qs
7 CROSS APPLY sys.dm_exec_sql_text(qs.plan_handle) st
8 CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp
9 order by plan_last_compiled desc

 

posted @ 2020-03-30 16:50  放飞梦想  阅读(3288)  评论(0编辑  收藏  举报