Today I’m going to cover trace flag 3604 & 3605. These two trace flags are used to print information’s or output from DBCC commands. As far as I know these two trace flags are widely used to get output for DBCC IND & DBCC PAGE commands. These two commands will not print anything unless or until you enable any one of these trace flags
Trace Flag 3604
Enabling this trace flag will give the output of DBCC commands to screen or prints the output to result window. I’m going to enable this trace flag session scoped only. You can check my article “Enable \ Disable Trace Flag in SQL Server” for enabling it in multiple ways.
--Turning on trace flag 3604 DBCC TRACEON(3604) GO --Going to check dbid 4(msdb), file id 1 and page 1 DBCC PAGE(4,1,1)
I have now enabled and ran the DBCC command to get 1st page information of msdb database as shown below. If you haven’t turned on this trace flag you won’t be able to see the output.
To turn off this trace flag run the command below
--Turning off trace flag DBCC TRACEOFF(3604)
Trace Flag 3605
This flag is similar to trace flag 3604 which will write the output of the command to errorlog instead of displaying it in SSMS console. I’m going to enable this session scoped only.
--Turning on trace flag 3605 DBCC TRACEON(3605) GO --Going to check dbid 4(msdb), file id 1 and page 1 DBCC PAGE(4,1,1)
Now from the output below you can see that the output is not displayed in console.
To get the output you need to check errorlog, the output will be written to errorlog as shown below
To turn it off use the command below
--Turning off trace flag DBCC TRACEOFF(3605)
These two trace flags are not documented in MS website, so careful while playing with it. You can use these trace flags to get information from commands to display it in console or to print in errorlog.