In SQL Server 2005, there are two types of trace flags: session and global. Session trace flags are active for a connection and are visible only to that connection. Global trace flags are set at the server level and are visible to every connection on the server. Some flags can only be enabled as global, and some can be enabled at either global or session scope.
The following rules apply:
-
A global trace flag must be enabled globally. Otherwise, the trace flag has no effect. We recommend that you enable global trace flags at startup, by using the -T command line option.
-
If a trace flag has either global or session scope, it can be enabled with the appropriate scope. A trace flag that is enabled at the session level never affects another session, and the effect of the trace flag is lost when the SPID that opened the session logs out.
Trace flags are set on or off by using either of the following methods:
-
Using the DBCC TRACEON and DBCC TRACEOFF commands.
For example, DBCC TRACEON 2528: To enable the trace flag globally, use DBCC TRACEON with the -1 argument: DBCC TRACEON 2528, -1. To turn off a global trace flag, use DBCC TRACEOFF with the -1 argument.
-
Using the -T startup option to specify that the trace flag be set on during startup.
The -T startup option enables a trace flag globally. You cannot enable a session-level trace flag by using a startup option. For more information about startup options, see Using the SQL Server Service Startup Options.
Use the DBCC TRACESTATUS command to determine which trace flags are currently active.
Behavior Changes
In SQL Server 2000, a simple DBCC TRACEON (1204) is enough to enable deadlock reporting to the error log. In SQL Server 2005, you must enable the flag globally because the session-level flag is not visible to the deadlock monitor thread.
For more information about changes in behavior, see Breaking Changes to Database Engine Features in SQL Server 2005.