Trace flags are valuable tools as they allow DBA to enable or disable a database function temporarily. Once a trace flag is turned on, it remains on until either manually turned off or SQL Server restarted. Only users in the sysadmin fixed server role can turn on trace flags.

If you want to enable/disable Detailed Deadlock Information (1204), use Query Analyzer and DBCC TRACEON to turn it on.
Trace flag 1204 sends detailed information about the deadlock to the error log. It works only at server level, so for deadlocks turn it on with the -1 option shown below.
Enable Trace at current connection level:
DBCC TRACEON(1204)
Disable Trace:
DBCC TRACEOFF(1204)
Enable Multiple Trace at same time separating each trace with a comma.
DBCC TRACEON(1204,2528)
Disable Multiple Trace at same time separating each trace with a comma.
DBCC TRACEOFF(1204,2528)
To set the trace using the DBCC TRACEON command at a server level, Pass second argument to the function as -1.
DBCC TRACEON (1204, -1)
To enumerate a complete list of traces that are on run following command in query analyzer.
DBCC TRACESTATUS(-1)
SQL Server 2005 Trace Flags.
SQL Server 2000 SP3 Trace Flags. (Undocumented trace flags are not included in document)
Using Trace Flags Safely on a Real Server
A flag turned on with DBCC TRACEON does not survive a restart. If you need it to stay on, add it as a startup parameter, such as -T1222, in SQL Server Configuration Manager. Then it is active from the moment the service starts.
For deadlocks on SQL Server 2005 and later, many DBAs prefer trace flag 1222. It writes the deadlock details to the error log in a format that is easier to read than the older output. Newer versions also capture deadlocks in the built in system_health Extended Events session, so you may not need a flag at all.
A few habits I follow:
- Try a flag on a test server first, and read what it does before you turn it on.
- Keep a short note of every flag you enable, when, and why.
- Run
DBCC TRACESTATUS(-1)after a restart or a patch to confirm what is really on. - Stay away from undocumented flags unless Microsoft support asks you to use one.
- Check the scope of a flag. Some work only when turned on globally, which means passing -1 as the second argument.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.





6 Comments. Leave new
Where can I find a complete list of trace flags?
Hi Smark,
If you read the post above. I have listed links to all the Trace Flags in the post itself.
Regards,
Pinal Dave (SQLAuthority.com)
That is not a complete list, it doesn’t include flags like 3226 to hide error messages or 3106 which is required when you want to move the system databases. If you know of a complete list please re-post.
Correction, 3226 hides successful backup messages
Hi:
I have an sql 2000 server i want to trace the database .
More explicity i want to monitoring all the TSQL Sentences than the users execute in the database by user or Host_ID without using the SQL PROFILER.
There are any Function or any query than i can execute i bring me that information similar than the SQL Profiler show??
Thank very Much
Emiliano Gallo
emiliano.gallo@gmail.com
We have some issue with deadlock coz in a single transaction we r calling around 10 sps.due to that when multiple users try to do the same process,it gets locked.Could you please give any suggestion for this.