September 22, 2006 at 3:29 am
Hi,
I am planning to implement a trace using the
sp_trace_create, sp_trace_setevent and sp_trace_setstatus.
Could anyone tell me if it is possible to list all currently running traces. For example if I have neglected to collect to traceid from sp_trace_create, how can I find that id and stop it and then use sp_trace_setstatus @status = 2 to stop it
Regards
Simon
September 22, 2006 at 6:46 am
You may try this if you know,
To find out all the running traces you may use below sql
SELECT * FROM ::fn_trace_getinfo(DEFAULT)
and if you want to stop it particular trace file replace like search string and run below sql
DECLARE @TraceId INT
IF EXISTS (SELECT * FROM ::fn_trace_getinfo(DEFAULT) WHERE CAST(Value AS VARCHAR(126)) LIKE '%MySqlTrace%' AND Property = 2)
BEGIN
PRINT 'Trace is running and I am stopping it...'
SELECT @TraceId = TraceId FROM ::fn_trace_getinfo(DEFAULT) WHERE CAST(Value AS VARCHAR(126)) LIKE '%MySqlTrace%' AND Property = 2
EXEC master..sp_trace_setstatus @TraceId = @TraceId,@Status=0
EXEC master..sp_trace_setstatus @TraceId = @TraceId,@Status=2
END
Ram
September 22, 2006 at 7:58 am
>>SELECT * FROM ::fn_trace_getinfo(DEFAULT) <<
Cheers Ram
that's exactly what I'm after
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply