This article takes you to describing about the Trace Flags and its usage in SQL Server.
Common Terms Used:
DBCC TRACEON
DBCC TRACEOFF
DBCC TRACESTATUS
Trace flags can be enabled at session level or global level. Session level trace flags are available and active for that connection whereas Global Trace flags are available and active throughout the server.
Global Trace flag is enabled at server level at startup with a –T parameter used in it.
Session level Trace flags are enabled using DBCC TRACEON command, we can find the trace that are active using the DBCC TRACESTATUS command and can be disabled using DBCC TRACEOFF command.
Trace flag | Description |
-1 | Sets trace flags for all client connections, rather than for a single client connection. Because trace flags set using the -T command-line option automatically apply to all connections, this trace flag is used only when setting trace flags using DBCC TRACEON and DBCC TRACEOFF. |
106 | Disables line number information for syntax errors. |
107 | Interprets numbers with a decimal point as float instead of decimal. |
205 | Report when a statistics-dependent stored procedure is being recompiled as a result of AutoStat. |
206 | Provides backward compatibility for the setuser statement. |
208 | SET QUOTED IDENTIFIER ON. |
242 | Provides backward compatibility for correlated subqueries where non-ANSI-standard results are desired. |
243 | The behavior of SQL Server is now more consistent because nullability checks are made at run time and a nullability violation results in the command terminating and the batch or transaction process continuing. |
244 | Disables checking for allowed interim constraint violations. By default, SQL Server checks for and allows interim constraint violations. An interim constraint violation is caused by a change that removes the violation such that the constraint is met, all within a single statement and transaction. SQL Server checks for interim constraint violations for self-referencing DELETE statements, INSERT, and multirow UPDATE statements. This checking requires more work tables. With this trace flag you can disallow interim constraint violations, thus requiring fewer work tables. |
257 | Will invoke a print algorithm on the XML output before returning it to make the XML result more readable. |
260 | Prints the versioning information about extended stored procedure dlls. |
302 | Prints information about whether the statistics page is used, the actual selectivity (if available), and what SQL Server estimated the physical and logical I/O would be for the indexes. Trace flag 302 should be used with trace flag 310 to show the actual join ordering. |
310 | Prints information about join order. Index selection information is also available in a more readable format using SET SHOWPLAN_ALL, as described in the SET statement. |
325 | Prints information about the cost of using a nonclustered index or a sort to process an ORDER BY clause. |
326 | Prints information about the estimated and actual cost of sorts. |
330 | Enables full output when using the SET SHOWPLAN_ALL option, which gives detailed information about joins. |
506 | Enforces SQL-92 standards regarding null values for comparisons between variables and parameters. Any comparison of variables and parameters that contain a NULL always results in a NULL. |
652 | Disables read ahead for the server. |
653 | Disables read ahead for the current connection. |
809 | Limits the amount of Lazy Write activity in SQL Server 2000. |
1180 | Forces allocation to use free pages for text or image data and maintain efficiency of storage. |
1200 | Prints lock information (the process ID and type of lock requested). |
1204 | Returns the type of lock participating in the deadlock and the current command affect by the deadlock. |
1205 | Returns more detailed information about the command being executed at the time of a deadlock. |
1206 | Used to complement flag 1204 by displaying other locks held by deadlock parties |
1609 | Turns on the unpacking and checking of remote procedure call (RPC) information in Open Data Services. Used only when applications depend on the old behavior. |
1704 | Prints information when a temporary table is created or dropped. |
1807 | Allows you to configure SQL Server with network-based database files. |
2505 | Prevents DBCC TRACEON 208, SPID 10 errors from appearing in the error log. |
2508 | Disables parallel non-clustered index checking for DBCC CHECKTABLE. |
2509 | Used with DBCC CHECKTABLE.html to see the total count of ghost records in a table |
2528 | Disables parallel checking of objects by DBCC commands. |
2701 | Sets the @@ERROR system function to 50000 for RAISERROR messages with severity levels of 10 or less. When disabled, sets the @@ERROR system function to 0 for RAISERROR messages with severity levels of 10 or less. |
3104 | Causes SQL Server to bypass checking for free space. |
3111 | Cause LogMgr::ValidateBackedupBlock to be skipped during backup and restore operations. |
3205 | Disables hardware compression for tape drivers. |
3222 | Disables the read ahead that is used by the recovery operation during roll forward operations. |
3502 | Prints a message to the log at the start and end of each checkpoint. |
3503 | Indicates whether the checkpoint at the end of automatic recovery was skipped for a database (this applies only to read-only databases). |
3602 | Records all error and warning messages sent to the client. |
3604 | Sends trace output to the client. Used only when setting trace flags with DBCC TRACEON and DBCC TRACEOFF. |
3605 | Sends trace output to the error log. (If you start SQL Server from the command prompt, the output also appears on the screen.) |
3607 | Skips automatic recovery (at startup) for all databases. |
3608 | Skips automatic recovery (at startup) for all databases except the master database. |
3609 | Skips the creation of the tempdb database at startup. Use this trace flag if the device or devices on which tempdb resides are problematic or problems exist in the model database. |
3626 | Turns on tracking of the CPU data for the sysprocesses table. |
3640 | Eliminates the sending of DONE_IN_PROC messages to the client for each statement in a stored procedure. This is similar to the session setting of SET NOCOUNT ON, but when set as a trace flag, every client session is handled this way. |
4022 | Bypasses automatically started procedures. |
4030 | Prints both a byte and ASCII representation of the receive buffer. Used when you want to see what queries a client is sending to SQL Server. You can use this trace flag if you experience a protection violation and want to determine which statement caused it. Typically, you can set this flag globally or use SQL Server Enterprise Manager. You can also use DBCC INPUTBUFFER. |
4031 | Prints both a byte and ASCII representation of the send buffers (what SQL Server sends back to the client). You can also use DBCC OUTPUTBUFFER. |
4032 | Traces the SQL commands coming in from the client. The output destination of the trace flag is controlled with the 3605/3604 trace flags. |
7300 | Retrieves extended information about any error you encounter when you execute a distributed query. |
7501 | Dynamic cursors are used by default on forward-only cursors. Dynamic cursors are faster than in earlier versions and no longer require unique indexes. This flag disables the dynamic cursor enhancements and reverts to version 6.0 behavior. |
7502 | Disables the caching of cursor plans for extended stored procedures. |
7505 | Enables version 6.x handling of return codes when calling dbcursorfetchex and the resulting cursor position follows the end of the cursor result set. |
7525 | Reverts to the SQL Server 7.0 behavior of closing nonstatic cursors regardless of the SET CURSOR_CLOSE_ON_COMMIT state in SQL Server 2000. |
8202 | Replicates all UPDATE commands as DELETE/INSERT pairs at the publisher. |
8206 | Supports stored procedure execution with a user specified owner name for SQL Server subscribers or without owner qualification for heterogeneous subscribers in SQL Server 2000. |
8207 | Enables singleton updates for Transactional Replication, released with SQL Server 2000 Service Pack 1. |
8599 | Allows you to use a savepoint within a distributed transaction. |
8679 | Prevents the SQL Server optimizer from using a Hash Match Team operator. |
8687 | Used to disable query parallelism. |
8721 | Dumps information into the error log when AutoStat has been run. |
8783 | Allows DELETE, INSERT, and UPDATE statements to honor the SET ROWCOUNT ON setting when enabled. |
8816 | Logs every two-digit year conversion to a four-digit year. |
260 | Prints versioning information about extended Stored procedured dynamic link libraries |
1204 | Returns the resources and types of locks participating in a deadlock and also the current command affected. |
1211 | Disables lock escalation based on memory pressure, or based on number of locks. The SQL Server Database Engine will not escalate row or page locks to table locks.Using this trace flag can generate excessive numbers of locks. This can slow the performance of the Database Engine, or cause 1204 errors (unable to allocate lock resource) because of insufficient memory. If both trace flag 1211 and 1224 are set, 1211 takes precedence over 1224. However, because trace flag 1211 prevents escalation in every case, even under memory pressure, we recommend that you use 1224. This helps avoid "out-of-locks" errors when many locks are being used. |
1222 | Returns the resources and types of locks that are participating in a deadlock and also the current command affected, in an XML format that does not comply with any XSD schema. |
1224 | Disables lock escalation based on the number of locks. However, memory pressure can still activate lock escalation. The Database Engine escalates row or page locks to table (or partition) locks if the amount of memory used by lock objects exceeds one of the following conditions:Forty percent of the memory that is used by Database Engine, exclusive of memory allocation using Address Windowing Extension (AWE). This is applicable only when the locks parameter of sp_configure is set to 0.Forty percent of the lock memory that is configured by using the locks parameter of sp_configure. If both trace flag 1211 and 1224 are set, 1211 takes precedence over 1224. However, because trace flag 1211 prevents escalation in every case, even under memory pressure, we recommend that you use 1224. This helps avoid "out-of-locks" errors when many locks are being used.Lock escalation to the table- or HoBT-level granularity can also be controlled by using the LOCK_ESCALATION option of the ALTER TABLEstatement. |
2528 | Disables parallel checking of objects by DBCC CHECKDB, DBCC CHECKFILEGROUP, and DBCC CHECKTABLE. By default, the degree of parallelism is automatically determined by the query processor. The maximum degree of parallelism is configured just like that of parallel queries. For more information, see max degree of parallelism Option.Parallel DBCC should typically be left enabled. For DBCC CHECKDB, the query processor reevaluates and automatically adjusts parallelism with each table or batch of tables checked. Sometimes, checking may start when the server is almost idle. An administrator who knows that the load will increase before checking is complete may want to manually decrease or disable parallelism.Disabling parallel checking of DBCC can cause DBCC to take much longer to complete and if DBCC is run with the TABLOCK feature enabled and parallelism set off, tables may be locked for longer periods of time. |
3205 | By default, if a tape drive supports hardware compression, either the DUMP or BACKUP statement uses it. With this trace flag, you can disable hardware compression for tape drivers. This is useful when you want to exchange tapes with other sites or tape drives that do not support compression. |
3226 | By default, every successful backup operation adds an entry in the SQL Server error log and in the system event log. If you create very frequent log backups, these success messages accumulate quickly, resulting in huge error logs in which finding other messages is problematic.With this trace flag, you can suppress these log entries. This is useful if you are running frequent log backups and if none of your scripts depend on those entries. |
3608 | Prevents SQL Server from automatically starting and recovering any database except the master database. Databases will be started and recovered when accessed. Some features, such as snapshot isolation and read committed snapshot, might not work. Use for Moving System Databases and Moving User Databases. Do not use during normal operation. |
3625 | Limits the amount of information returned in error messages. For more information, see Metadata Visibility Configuration. |
4616 | Makes server-level metadata visible to application roles. In SQL Server, an application role cannot access metadata outside its own database because application roles are not associated with a server-level principal. This is a change of behavior from earlier versions of SQL Server. Setting this global flag disables the new restrictions, and allows for application roles to access server-level metadata. |
6527 | Disables generation of a memory dump on the first occurrence of an out-of-memory exception in CLR integration. By default, SQL Server generates a small memory dump on the first occurrence of an out-of-memory exception in the CLR. The behavior of the trace flag is as follows:If this is used as a startup trace flag, a memory dump is never generated. However, a memory dump may be generated if other trace flags are used.If this trace flag is enabled on a running server, a memory dump will not be automatically generated from that point on. However, if a memory dump has already been generated due to an out-of-memory exception in the CLR, this trace flag will have no effect. |
7806 | Enables a dedicated administrator connection (DAC) on SQL Server Express. By default, no DAC resources are reserved on SQL Server Express. For more information, see Using a Dedicated Administrator Connection. |