Trace filter not working correctly

  • Having two filters works fine in profiler but when i script and run as a trace the filter is ignored. If I comment out one of the filters it works fine for the remaining filter.

    declare @rc int

    declare @TraceID int

    declare @maxfilesize bigint

    set @maxfilesize = 5

    exec @rc = sp_trace_create @TraceID output, 0, N'd:\TraceData\dmlfrome', @maxfilesize, NULL

    if (@rc != 0) goto error

    print @TraceID

    print @rc

    declare @on bit

    set @on = 1

    exec sp_trace_setevent @TraceID, 10, 15, @on

    exec sp_trace_setevent @TraceID, 10, 10, @on

    exec sp_trace_setevent @TraceID, 10, 11, @on

    exec sp_trace_setevent @TraceID, 10, 35, @on

    exec sp_trace_setevent @TraceID, 10, 12, @on

    exec sp_trace_setevent @TraceID, 10, 6, @on

    exec sp_trace_setevent @TraceID, 10, 14, @on

    exec sp_trace_setevent @TraceID, 12, 15, @on

    exec sp_trace_setevent @TraceID, 12, 1, @on

    exec sp_trace_setevent @TraceID, 12, 6, @on

    exec sp_trace_setevent @TraceID, 12, 10, @on

    exec sp_trace_setevent @TraceID, 12, 14, @on

    exec sp_trace_setevent @TraceID, 12, 11, @on

    exec sp_trace_setevent @TraceID, 12, 35, @on

    exec sp_trace_setevent @TraceID, 12, 12, @on

    declare @intfilter int

    declare @bigintfilter bigint

    --exec sp_trace_setfilter @TraceID, 10, 0, 7, N'REPLICATION MONITOR'

    exec sp_trace_setfilter @TraceID, 11, 1, 6, N'e%'

    exec sp_trace_setstatus @TraceID, 1

    goto finish

    error:

    select ErrorCode=@rc

    finish:

    go


    John Zacharkan

  • What exactly you want to flter out?

    Mj

  • I had two filters -

    1) Include only logins that start with the letter 'E'

    2) Exclude Appplications that are 'REPLICATION MONITOR'

    When I run my profiler interactive this works, if I save it off to and run the trace the filters are ignored. If I comment out filter 2 the filter works for 1, if I comment out 1 filter 1 works.


    John Zacharkan

  • Try:

    exec sp_trace_setfilter @TraceID, 10, 0, 7, N'REPLICATION MONITOR'

    exec sp_trace_setfilter @TraceID, 11, 0, 6, N'e%'

    Hope this works!

    MJ

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply