Help: SQL Server

Sharing my knowlege about SQL Server Troubleshooting Skills

  • Blog Stats

    • 2,039,818 hits
  • Select GETDATE()

    April 2023
    M T W T F S S
     12
    3456789
    10111213141516
    17181920212223
    24252627282930

Posts Tagged ‘DBCC TRACEON’

Help : How to suppress DBCC TRACEON/OFF messages in the Error Log?

Posted by blakhani on December 9, 2014


This has been asked into a forum recently (here). I remember that there was a way in SQL 7.0 so I searched and found KB 243352. As per KB article trace Flag 2505 can do that. I decided to test in SQL Server 2014 to see if it still works and I was happy to see that it is still working.

Trace flag 2505 works as DBCC TRACEON and Startup parameter as well. Here is the script to test it.

-- recycle the error log
EXEC sp_cycle_errorlog
-- turn on deadlock logging trace flag 
DBCC TRACEON (1222, -1)
GO
-- Read ERRORLOG using filter.
EXEC xp_readerrorlog 0, 1, N'dbcc'
go
-- turn off deadlock logging trace flag 
DBCC TRACEOFF (1222, -1)
GO
--Read ERRORLOG
EXEC xp_readerrorlog 0, 1, N'dbcc'
go
-- Now magic trace flag
DBCC TRACEON (2505, -1)
GO
-- 1204 to check if this is logged.
DBCC TRACEON (1204, -1)
GO
-- read ERRORLOG again
EXEC xp_readerrorlog 0, 1, N'dbcc'
go
-- Turn off magic trace flag
DBCC TRACEOFF (2505, -1)
GO

After 1222 Turn ON

LogDate ProcessInfo Text ----------------------- ------------ ------------------------------------------------------------------------------------------------------------------- 2014-12-09 05:14:03.920 spid59 DBCC TRACEON 1222, server process ID (SPID) 59. This is an informational message only; no user action is required. (1 row(s) affected)
After 1222 Turn OFF LogDate ProcessInfo Text ----------------------- ------------ ----------------------------------------------------------------------------------------------------------------- 2014-12-09 05:14:03.920 spid59 DBCC TRACEON 1222, server process ID (SPID) 59. This is an informational message only; no user action is required. 2014-12-09 05:14:03.970 spid59 DBCC TRACEOFF 1222, server process ID (SPID) 59. This is an informational message only; no user action is required. (2 row(s) affected)


After 2505 and 1204 were ON LogDate ProcessInfo Text ----------------------- ------------ ----------------------------------------------------------------------------------------------------------------- 2014-12-09 05:14:03.920 spid59 DBCC TRACEON 1222, server process ID (SPID) 59. This is an informational message only; no user action is required. 2014-12-09 05:14:03.970 spid59 DBCC TRACEOFF 1222, server process ID (SPID) 59. This is an informational message only; no user action is required.

As we can see in last output, there are no additional entries made in ERRORLOG for 1204. Interestingly there is no entry for 2505 itself. 

Note that this trace flag is not listed in documentation other than SQL 7.0 KB article which I mentioned above. So please don’t shoot me if it doesn’t work in any version other than SQL 7.0 but I don’t see any reason why this functionality would be removed.

Hope this helps.

  • Cheers,
  • Balmukund Lakhani
  • Twitter @blakhani
  • Advertisement

    Posted in SQL Server, Trace Flag | Tagged: , , , , , | 2 Comments »