This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a TSQL script to find the status of SQL Server Trace.
The SQL Server Trace is very important for tracing the different SQL Server events like errors, object changes information and others.
Using this script you can find different information of the Trace like Trace is running or not, Type of the trace, File path of the trace.
You can also visit this article to enable and disable SQL Server Default Trace.
I am fetching require trace column using an sys.traces.
Below is a script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
SELECT CASE T.is_default WHEN 1 THEN 'Default/System Trace' WHEN 0 THEN 'User Defined Trace' END AS TraceType ,CASE T.status WHEN 1 THEN 'Running' WHEN 0 THEN 'Stopped' END AS TraceStrace ,ES.session_id AS SessionID ,ES.login_name AS LoginName ,T.Path AS TraceFilePath FROM sys.traces AS T LEFT JOIN sys.dm_exec_sessions AS ES ON T.reader_spid = ES.session_id |