• Hey

    I am getting an error on adding the event

    DECLARE @return_code INT;

    DECLARE @TraceID INT;

    DECLARE @maxfilesize BIGINT;

    SET @maxfilesize = 5;

    --step 1: create a new empty trace definition

    EXEC sp_trace_create

    @traceid OUTPUT

    , @options = 2

    , @tracefile = N'd:\LongRunningQueries'

    , @maxfilesize = @maxfilesize

    , @stoptime =NULL

    , @filecount = 2;

    -- step 2: add the events and columns

    EXEC sp_trace_setevent

    @traceid = @TraceID

    , @eventid = 10 -- RPC:Completed

    , @columnid = 1 -- TextData

    , @on = 1;--include this column in trace

    Gives me

    Msg 214, Level 16, State 3, Procedure sp_trace_setevent, Line 1

    Procedure expects parameter '@on' of type 'bit'.

    The trace is created, it's just the event selection that fails I guess (didn't try running it).

    It's probably something simple, I just can't see it - any bright ideas?

    By the way great article, reading it with great interest - only ever used the GUI profiler before (I haven't gotten to section 3 yet, but I hope there is a way of converting the GUI profiler trace setting to a script as mentioned in section 1)

    /Jon