Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 TransactionID column in trace files (.trc)

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-06 : 08:26:44
Pablo J. Rogina writes "While creating a trace file in SQL 2K, and setting several columns, I'm setting also column 4, with code like this:

DECLARE @RC int, @TraceID int, @ON bit, @dbID int
SET @ON = 1
EXEC @RC = sp_trace_create @TraceID OUTPUT, 0, N'c:\Temp\t04_trace'
SELECT 'RC'= @RC, 'TraceID'= @TraceID
-- SQL:StmtCompleted Event, Text Column
EXEC @RC = sp_trace_setevent @TraceID, 41, 1, @ON
-- SQL:StmtCompleted Event, Database ID Column
EXEC @RC = sp_trace_setevent @TraceID, 41, 3, @ON
-- SQL:StmtCompleted Event, TransactionID Column
EXEC @RC = sp_trace_setevent @TraceID, 41, 4, @ON
-- SQL:StmtCompleted Event, NTUserName Column
EXEC @RC = sp_trace_setevent @TraceID, 41, 6, @ON
-- SQL:StmtCompleted Event, NTDomainName Column
EXEC @RC = sp_trace_setevent @TraceID, 41, 7, @ON

The problem is that column 4 (TransactionID) is always NULL, no matter what I've tried (named transactions, implicits transactions, etc.). Even if I create a trace file in Profiler, TransactionID column gets no value other than NULL.

I'd like to join the trace file with the Transaction Log and think I need this column.

Is there anything I'm doing wrong?

Thank you in advance.

Pablo J. Rogina"
   

- Advertisement -