SELECT
qs.creation_time,
qs.last_execution_time,
qs.execution_count,
qs.total_worker_time AS CPU_Time,
qs.total_elapsed_time AS Total_Elapsed_Time,
st.text AS SQL_Text,
qp.query_plan AS Query_Plan
FROM
sys.dm_exec_query_stats AS qs
CROSS APPLY
sys.dm_exec_sql_text(qs.sql_handle) AS st
CROSS APPLY
sys.dm_exec_query_plan(qs.plan_handle) AS qp
ORDER BY
qs.last_execution_time DESC;
chatgpt给的 肯定有的 你去网上搜一下