Friday, 4 November 2011

SQL Server Black Box Trace

A blackboc trace on SQL server captrues the last 5Mb of SQL server activity. This is useful for identifying what was running ast the time of any server crash. To start a blackbox trace
DECLARE @traceId int EXEC sp_trace_create @traceId output, 8 EXEC sp_trace_setstatus @traceId, 1
By default the trace file will be created in C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA To load the trace files for inspection:
SELECT * INTO temp_trc FROM fn_trace_gettable('C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\blackbox.trc', default);

No comments:

Post a Comment