Friday, January 2, 2015

How find running trace/profiler , location and stop/pause/close/delete trace

Run the below one of Script to see status of Trace
SELECT * FROM ::fn_trace_getinfo(default)

OR
 
Select [Status] =
case tr.[status]
when 1 THEN 'Running'
when 0 THEN 'Stopped'
end
,[Default] = case tr.is_default
when 1 THEN 'System TRACE'
when 0 THEN 'User TRACE'
end
,[login_name]= coalesce(se.login_name,se.login_name,'No reader spid')
,[Trace Path] = coalesce(tr.[Path],tr.[Path],'OLE DB Client Side Trace')
from sys.traces tr
left join sys.dm_exec_sessions seon tr.reader_spid= se.session_id
 
Use below script to stop or delete trace:
-- These are examples
EXEC sp_trace_setstatus @traceid = 3, @status = 0; -- Stop/pause Trace
EXEC sp_trace_setstatus @traceid = 3, @status = 2; -- Close/ delete Trace 

No comments:

Post a Comment