Follow SQLMaster on Twitter
Welcome to SqlServer-QA.net Sign in | Help

SQL Server: Creating BlackBox kind of trace with TSQL

Here is the kind of scripts defined within TEchnet articles about running black-box kind of traces against your SQL Server instance, then also you can  take advantage of the blackbox trace if you are facing intermittent problems, you want to make sure that it is always running when your server is running—including after either a planned or unplanned restart. To accomplish this, you can set the blackbox trace to start automatically when SQL Server starts. First, wrap the trace definition in a stored procedure in the master database:

 --Transact-SQL can be used to start a blackbox trace

USE master
GO
CREATE PROCEDURE StartBlackBoxTrace
AS
BEGIN
DECLARE @TraceId int
DECLARE @maxfilesize bigint
SET @maxfilesize = 25
EXEC sp_trace_create
@TraceId OUTPUT,
@options = 8,
@tracefile = NULL,
@maxfilesize = @maxfilesize
EXEC sp_trace_setstatus @TraceId, 1
END
GO

 Next, set the procedure to start automatically when the SQL Server service is started:

EXEC sp_procoption 'StartBlackBoxTrace', 'STARTUP', 'ON'

Published Wednesday, May 28, 2008 4:59 AM by SQL Master

Comments

# SQL Server: Creating BlackBox kind of trace with TSQL

Here is the kind of scripts defined within TEchnet articles about running black-box kind of traces against

Wednesday, May 28, 2008 5:03 AM by Other SQL Server Blogs around the Web

# SQL Server Transact-SQL (SSQA.net) : SQL Server: Creating BlackBox kind of trace with TSQL

Anonymous comments are disabled