Trouble with Traces

  • Hi,

    I've got a trace running in profiler - the tsql duration, filtered above 1000ms.  I've scripted it for 2000 and it is running on the server.  I'm not getting any contents in the file though.  I created another, just a tsql trace with no filters and put that on the server - it filled up 5mb in a few seconds.  If I run the trace in profiler, I entries.  We are running a cluster with sp4. 

    The trace files have been created, but are 0kb

    Here is my trace code:

     

    /****************************************************/

    /* Created by: SQL Profiler                         */

    /* Date: 03/06/2007  08:51:09 AM         */

    /****************************************************/

    -- Create a Queue

    declare @rc int

    declare @TraceID int

    declare @maxfilesize bigint

    set @maxfilesize = 5

    -- Please replace the text InsertFileNameHere, with an appropriate

    -- filename prefixed by a path, e.g., c:\MyFolder\MyTrace. The .trc extension

    -- will be appended to the filename automatically. If you are writing from

    -- remote server to local drive, please use UNC path and make sure server has

    -- write access to your network share

    exec @rc = sp_trace_create @TraceID output, 0, N'G:\Traces\Duration', @maxfilesize, NULL

    if (@rc != 0) goto error

    -- Client side File and Table cannot be scripted

    -- Set the events

    declare @on bit

    set @on = 1

    exec sp_trace_setevent @TraceID, 10, 1, @on

    exec sp_trace_setevent @TraceID, 10, 3, @on

    exec sp_trace_setevent @TraceID, 10, 6, @on

    exec sp_trace_setevent @TraceID, 10, 8, @on

    exec sp_trace_setevent @TraceID, 10, 10, @on

    exec sp_trace_setevent @TraceID, 10, 12, @on

    exec sp_trace_setevent @TraceID, 10, 13, @on

    exec sp_trace_setevent @TraceID, 10, 14, @on

    exec sp_trace_setevent @TraceID, 10, 16, @on

    exec sp_trace_setevent @TraceID, 10, 17, @on

    exec sp_trace_setevent @TraceID, 10, 40, @on

    exec sp_trace_setevent @TraceID, 12, 1, @on

    exec sp_trace_setevent @TraceID, 12, 3, @on

    exec sp_trace_setevent @TraceID, 12, 6, @on

    exec sp_trace_setevent @TraceID, 12, 8, @on

    exec sp_trace_setevent @TraceID, 12, 10, @on

    exec sp_trace_setevent @TraceID, 12, 12, @on

    exec sp_trace_setevent @TraceID, 12, 13, @on

    exec sp_trace_setevent @TraceID, 12, 14, @on

    exec sp_trace_setevent @TraceID, 12, 16, @on

    exec sp_trace_setevent @TraceID, 12, 17, @on

    exec sp_trace_setevent @TraceID, 12, 40, @on

    -- Set the Filters

    declare @intfilter int

    declare @bigintfilter bigint

    exec sp_trace_setfilter @TraceID, 10, 0, 7, N'SQL Profiler'

    set @bigintfilter = 999

    exec sp_trace_setfilter @TraceID, 13, 0, 4, @bigintfilter

     

    -- Set the trace status to start

    exec sp_trace_setstatus @TraceID, 1

    -- display trace id for future references

    select TraceID=@TraceID

    goto finish

    error:

    select ErrorCode=@rc

    finish:

    go

  • I think you should also include @columnid = 13 in your trace setting to be able to apply a filter on it.

    I cannot test it right now.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • sp_trace_setfilter [ @traceid = ] trace_id

        , [ @columnid = ] column_id

        , [ @logical_operator = ] logical_operator

        , [ @comparison_operator = ] comparison_operator

        , [ @value = ] value

     

    >>I think you should also include @columnid = 13 in your trace setting to be able to apply a filter on it.

    Isn't that specified in this command:

    exec sp_trace_setfilter @TraceID, 13, 0, 4, @bigintfilter

    and the column is being included with this statement (event 12, column 13):

    exec sp_trace_setevent @TraceID, 12, 13, @on

    Thanks for the help!

     

  • Seems like this started to work - just not instantly, it took some interval of time from me seeing entries in my client trace before i saw it in the servers trace file.  Strange. 

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

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