Last active
March 27, 2018 10:19
-
-
Save nire0510/da3150a55d1a6580db93 to your computer and use it in GitHub Desktop.
[Last Executions] Get the last executed queries for a specific database #database #ms-sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT deqs.last_execution_time AS [Time], | |
dest.text AS [Query], dest.* | |
FROM sys.dm_exec_query_stats AS deqs | |
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest | |
WHERE dest.dbid = DB_ID('DB_NAME') | |
ORDER BY deqs.last_execution_time DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment