Last active
March 21, 2024 12:11
-
-
Save ststeiger/04ed8331a0af2920271d81f5595bfe71 to your computer and use it in GitHub Desktop.
Find past executed queries by text in MSSQL
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 | |
t.[text], qs.creation_time | |
FROM sys.dm_exec_cached_plans AS p | |
CROSS APPLY sys.dm_exec_sql_text(p.plan_handle) AS t | |
JOIN sys.dm_exec_query_stats qs ON p.plan_handle = qs.plan_handle | |
-- WHERE t.[text] LIKE N'%something unique about your query%'; | |
WHERE t.[text] LIKE N'%CTE%' | |
-- AND t.text LIKE '%APP-APERTUR%' | |
ORDER BY qs.creation_time DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment