SELECT
deqs.creation_time,
dest.text AS [SQL Text],
deqs.execution_count,
deqs.total_elapsed_time,
deqs.total_worker_time
FROM
sys.dm_exec_query_stats AS deqs
CROSS APPLY
sys.dm_exec_sql_text(deqs.sql_handle) AS dest
--where dest.text like '%这个是我的条件,没有就不要这个条件%'
ORDER BY
deqs.creation_time DESC;
需要在master库中运行这段代码,否者无效