default trace in SQL Server

https://www.red-gate.com/simple-talk/sql/performance/the-default-trace-in-sql-server-the-power-of-performance-and-security-auditing/

–enabling default trace

sp_configure ‘show advanced options’, 1;
GO
RECONFIGURE;
GO
sp_configure ‘default trace enabled’, 1;
GO
RECONFIGURE;
GO

–querying default trace
SELECT *
FROM sys.fn_trace_gettable(CONVERT(VARCHAR(150), ( SELECT TOP 1
f.[value]
FROM sys.fn_trace_getinfo(NULL) f
WHERE f.property = 2
)), DEFAULT) T
JOIN sys.trace_events TE ON T.EventClass = TE.trace_event_id
AND name = ‘Object:Deleted’

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.