How to ascertain the path of an active SQL trace (2005 & 2000)

  • I have written a program in Java which gets the name of trace files from configured path. In the program at runtime we need to ascertain whether a given trace file is active or no.

    We use two ways to ascertain that -

    1. sys.traces catalog view

    2. fn_trace_getinfo

    Both the above methods return the results only of those traces that have been created using sp_create_trace or default traces. If there are any active traces created using SQL Profiler they are listed as

    id status path

    31NULL

    That is the path of the trace is NULL.

    Is there any way to confirm whether a give trace file (irrespective of being created by SQL profiler or sp_create_trace function) is active or no?

    Thanks in advance,

    Jyoti

  • fn_trace_getinfo returns five rows for every trace active. Property id 2 indicates the trace path and file, maybe you are not checking the correct property for the active trace

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • The status column tells you if a trace is active. The only possible statuses are 0 - stopped and 1 - active. This is alos property 5 from the results of fn_trace_getinfo.

    If you are only using SQL Server 2005/2008 you should use sys.traces.

  • elitejyo (2/3/2009)


    IIf there are any active traces created using SQL Profiler they are listed as

    id status path

    31NULL

    That is the path of the trace is NULL.

    It will be. With traces that profiler's running, as far as SQL's concerned it's not writing to a file. It's streaming the trace data to a client app that's doing something with it. What, SQL has not idea of. That's why the path is null.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • elitejyo (2/3/2009)


    created using SQL Profiler

    :blush: oops missed that one totally

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

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

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