This is my 42nd blog on SQL Server Trace Flag 4032 in the series of One Trace Flag a Day. You can go to all blogs under that series by clicking here.
Trace flag 4032 traces all the commands coming from clients. Here you can see the commands sent by client to SQL Server. Let me show you practically.
We can enable this trace flag globally. Let me enable it from startup parameters from SQL Server configuration Manager and restart the sql service.
Now run the below TSQL to check trace flag is ON or not and what is written to error log.
use master go exec sp_cycle_errorlog go DBCC TRACESTATUS() go exec xp_readerrorlog go
Trace flag 4032 is ON but nothing written about commands in error log. Turn on the trace flag 3605 to log these things in error log.
use master go DBCC TRACEON(3605,-1) go exec sp_cycle_errorlog go select name from sys.databases go exec xp_readerrorlog
From above output it is clear that commands are logged along with timing and SPID. If you ever used this trace flag ever for troubleshooting kind of thing then we will be more than happy to read your comments.
Don’t forget to turn off the trace flag 3605 and also remove the trace flag 4032 from startup parameters and restart the services.
use master go DBCC TRACEOFF(3605,-1) go
PS: Do not use trace flags in production environment without testing it on non production environments and without consulting because everything comes at a cost.
Prince Kumar Rastogi