HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlMinor

Sql Server trace? Who is running it and how to stop it?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sqlwhoandstoprunninghowservertrace

Problem

Can you please help me out in finding who is running SQL Server Trace(profiler) on Server machine.?

It looks like, some people are running trace on live system on SQL DB, which make application super slow.

We need to find out who is running that or who ran that in the past? any idea how to do this?

Thanks.

Solution

Run the SQL command below:

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 se on tr.reader_spid = se.session_id


Source:- https://mssqlwiki.com/2010/04/26/how-to-find-all-the-profiler-traces-running-on-my-sql-server/

Code Snippets

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 se on tr.reader_spid = se.session_id

Context

StackExchange Database Administrators Q#155338, answer score: 5

Revisions (0)

No revisions yet.