Google Custom Search

Wednesday, January 14, 2009

Introduction to SQL Server Trace Flags

               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



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.


Disables line number information for syntax errors.


Interprets numbers with a decimal point as float instead of decimal.


Report when a statistics-dependent stored procedure is being recompiled as a result of AutoStat.


Provides backward compatibility for the setuser statement.




Provides backward compatibility for correlated subqueries where non-ANSI-standard results are desired.


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.


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.


Will invoke a print algorithm on the XML output before returning it to make the XML result more readable.


Prints the versioning information about extended stored procedure dlls.


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.


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.


Prints information about the cost of using a nonclustered index or a sort to process an ORDER BY clause.


Prints information about the estimated and actual cost of sorts.


Enables full output when using the SET SHOWPLAN_ALL option, which gives detailed information about joins.


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.


Disables read ahead for the server.


Disables read ahead for the current connection.


Limits the amount of Lazy Write activity in SQL Server 2000.


Forces allocation to use free pages for text or image data and maintain efficiency of storage.


Prints lock information (the process ID and type of lock requested).


Returns the type of lock participating in the deadlock and the current command affect by the deadlock.


Returns more detailed information about the command being executed at the time of a deadlock.


Used to complement flag 1204 by displaying other locks held by deadlock parties


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.


Prints information when a temporary table is created or dropped.


Allows you to configure SQL Server with network-based database files.


Prevents DBCC TRACEON 208, SPID 10 errors from appearing in the error log.


Disables parallel non-clustered index checking for DBCC CHECKTABLE.


Used with DBCC CHECKTABLE.html to see the total count of ghost records in a table


Disables parallel checking of objects by DBCC commands.


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.


Causes SQL Server to bypass checking for free space.


Cause LogMgr::ValidateBackedupBlock to be skipped during backup and restore operations.


Disables hardware compression for tape drivers.


Disables the read ahead that is used by the recovery operation during roll forward operations.


Prints a message to the log at the start and end of each checkpoint.


Indicates whether the checkpoint at the end of automatic recovery was skipped for a database (this applies only to read-only databases).


Records all error and warning messages sent to the client.


Sends trace output to the client. Used only when setting trace flags with DBCC TRACEON and DBCC TRACEOFF.


Sends trace output to the error log. (If you start SQL Server from the command prompt, the output also appears on the screen.)


Skips automatic recovery (at startup) for all databases.


Skips automatic recovery (at startup) for all databases except the master database.


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.


Turns on tracking of the CPU data for the sysprocesses table.


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.


Bypasses automatically started procedures.


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.


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.


Traces the SQL commands coming in from the client. The output destination of the trace flag is controlled with the 3605/3604 trace flags.


Retrieves extended information about any error you encounter when you execute a distributed query.


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.


Disables the caching of cursor plans for extended stored procedures.


Enables version 6.x handling of return codes when calling dbcursorfetchex and the resulting cursor position follows the end of the cursor result set.


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.


Replicates all UPDATE commands as DELETE/INSERT pairs at the publisher.


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.


Enables singleton updates for Transactional Replication, released with SQL Server 2000 Service Pack 1.


Allows you to use a savepoint within a distributed transaction.


Prevents the SQL Server optimizer from using a Hash Match Team operator.


Used to disable query parallelism.


Dumps information into the error log when AutoStat has been run.


Allows DELETE, INSERT, and UPDATE statements to honor the SET ROWCOUNT ON setting when enabled.


Logs every two-digit year conversion to a four-digit year.


Prints versioning information about extended Stored procedured dynamic link libraries


Returns the resources and types of locks participating in a deadlock and also the current command affected.


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.


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.


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.


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.


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.


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.


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.


Limits the amount of information returned in error messages. For more information, see Metadata Visibility Configuration.


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.


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.


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.



SQL recovery said...

You can create a table which contains indexes in Microsoft SQL Server 2000. When you run DBCC CHECKDB command against the SQL Server database which contains this table, you won’t receive any error message. On the other hand, when you run a query which references the table, an access infringement could occur.

Alexis said...

At work with sql files I advise to use-repair your sql server,therefore tool is free as is known,has a lot of features,and can too extract housekeeping data from the source database and preview the data,that can be recovered.