Created
January 9, 2015 18:33
-
-
Save JohnLBevan/023913af3a2a0969d480 to your computer and use it in GitHub Desktop.
Get Recently Executed SQL (in date range / ignoring some common bits)
This file contains hidden or 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
| --get sql statements just executed; filtering out common junk | |
| SELECT top 100 deqs.last_execution_time AS [Time] | |
| , dest.TEXT AS [Query] | |
| , deqs.* | |
| FROM sys.dm_exec_query_stats AS deqs | |
| CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest | |
| where deqs.last_execution_time between '2015-01-08 16:20:00' and '2015-01-08 16:22:00' | |
| and total_logical_writes > 0 | |
| and dest.TEXT not like '--SQL%' | |
| and dest.TEXT not like '%FETCH%' | |
| and dest.TEXT not like '%SYSSERVERSESSIONS%' | |
| and dest.TEXT not like '%BATCH%' | |
| 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