Help: SQL Server

Sharing my knowlege about SQL Server Troubleshooting Skills

  • Blog Stats

    • 2,050,846 hits
  • Select GETDATE()

    December 2014
    M T W T F S S
    1234567
    891011121314
    15161718192021
    22232425262728
    293031  

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

    2 Responses to “Help : How to suppress DBCC TRACEON/OFF messages in the Error Log?”

    1. […] trace flag 2505 can be used. Wrote a blog post with experiment https://sqlserver-help.com/2014/12/09/help-how-to-suppress-dbcc-traceonoff-messages-in-the-error-log […]

    2. […] There is a trace flag available with SQL Server to suppress these messages. Help : How to suppress DBCC TRACEON/OFF messages in the Error Log? […]

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )

    Connecting to %s

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

     
    %d bloggers like this: