Skip to content

Instantly share code, notes, and snippets.

@Otterpohl
Created May 13, 2022 15:50
Show Gist options
  • Save Otterpohl/cd8172f121fd2ab92091490c83f8ae95 to your computer and use it in GitHub Desktop.
Save Otterpohl/cd8172f121fd2ab92091490c83f8ae95 to your computer and use it in GitHub Desktop.
Get the recent DBCC events executed
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