February 3, 2009 at 4:48 am
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
February 3, 2009 at 6:58 am
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" 😉
February 3, 2009 at 8:57 am
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.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
February 3, 2009 at 9:06 am
elitejyo (2/3/2009)
IIf there are any active traces created using SQL Profiler they are listed asid 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
February 3, 2009 at 10:33 am
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