SQL Server Tacklebox- P40: This book, as with almost all books, started out as an idea. I wanted to accumulate together those scripts and tools that I have built over the years so that DBAs could sort through them and perhaps adapt them for their own circumstances. | 7 Securing access to SQL Server on - Used byb sp_trace_setevent to turn on data columns for particular events DECLARE @traceError INT @TraceID INT @on BIT SET @on 1 -- Create the trace and store the output in traceError then test traceError for failure -- and alert the user if the trace cannot be started EXEC @traceError sp_trace_create @TraceID output 0 @traceFile @maxFileSize NULL IF @traceError 0 BEGIN PRINT Trace could not be started @traceError RETURN END -- Add events that we want to collect data on for the trace -- Audit Login events 14 exec sp_trace_setevent @TraceID 14 1 @on exec sp_trace_setevent @TraceID 14 9 @on exec sp_trace_setevent @TraceID 14 6 @on exec sp_trace_setevent @TraceID 14 10 @on exec sp_trace_setevent @TraceID 14 14 @on exec sp_trace_setevent @TraceID 14 11 @on exec sp_trace_setevent @TraceID 14 12 @on -- Audit Logout events 15 exec sp_trace_setevent @TraceID 15 15 @on exec sp_trace_setevent @TraceID 15 16 @on exec sp_trace_setevent @TraceID 15 9 @on exec sp_trace_setevent @TraceID 15 13 @on exec sp_trace_setevent @TraceID 15 17 @on exec sp_trace_setevent @TraceID 15 6 @on exec sp_trace_setevent @TraceID 15 10 @on exec sp_trace_setevent @TraceID 15 14 @on exec sp_trace_setevent @TraceID 15 18 @on exec sp_trace_setevent @TraceID 15 11 @on exec sp_trace_setevent @TraceID 15 12 @on -- ExistingConnection events 17 exec sp_trace_setevent @TraceID 17 12 @on exec sp_trace_setevent @TraceID 17 1 @on exec sp_trace_setevent @TraceID 17 9 @on exec sp_trace_setevent @TraceID 17 6 @on exec sp_trace_setevent @TraceID 17 10 @on exec sp_trace_setevent @TraceID 17 14 @on exec sp_trace_setevent -- RPC Completed events @TraceID 10 17 11 @on exec sp_trace_setevent @TraceID 10 15 @on exec sp_trace_setevent @TraceID 10 16 @on 195 7 Securing access to SQL Server exec sp_trace_setevent @TraceID 10 1 @on exec sp_trace_setevent @TraceID 10 9 @on exec sp_trace_setevent @TraceID 10 17 @on exec sp_trace_setevent @TraceID 10 10 @on exec sp_trace_setevent @TraceID 10 .