Created
May 13, 2022 15:50
-
-
Save Otterpohl/cd8172f121fd2ab92091490c83f8ae95 to your computer and use it in GitHub Desktop.
Get the recent DBCC events executed
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
DECLARE @TraceFileName NVARCHAR(400); | |
SELECT TOP 1 | |
@TraceFileName = path | |
FROM sys.traces | |
WHERE is_default = 1; | |
SELECT * | |
FROM sys.fn_trace_gettable(@TraceFileName, DEFAULT) AS t | |
WHERE ( | |
t.EventClass = 22 | |
AND t.Severity >= 17 | |
AND t.StartTime > DATEADD(dd, -30, GETDATE()) | |
) | |
OR | |
( | |
t.EventClass IN ( 92, 93 ) | |
AND t.StartTime > DATEADD(dd, -30, GETDATE()) | |
AND t.Duration > 15000000 | |
) | |
OR (t.EventClass IN ( 94, 95, 116 )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment