MSSQL: Check recently executed queries
Check recently executed queries:
SELECT
t.text AS QueryText,
s.execution_count,
s.last_execution_time
FROM
sys.dm_exec_query_stats AS s
CROSS APPLY
sys.dm_exec_sql_text(s.sql_handle) AS t
ORDER BY
s.last_execution_time DESC;
Check recently executed queries for a specific database:
SELECT
t.text AS QueryText,
s.execution_count,
s.last_execution_time
FROM
sys.dm_exec_query_stats AS s
CROSS APPLY
sys.dm_exec_sql_text(s.sql_handle) AS t
WHERE
DB_NAME(t.dbid) = 'DB_A55D4A_sahalinc'
ORDER BY
s.last_execution_time DESC;
创建时间:4/3/2025 7:22:39 PM
修改时间:4/3/2025 7:23:46 PM