SQL Server Health Check

Trace Flags In SQL Server

Updated
3 min read
Written by
Mark Varnas

What are trace flags in SQL Server?

SQL Server trace flags are configuration handles that can enable or disable specific SQL Server characteristics or change a particular SQL Server behavior.

Trace flags turn on/off certain hidden SQL Server features that have no user interface components.

Trace flags may also be recommended by Microsoft Support to address behavior that is negatively impacting a specific workload.

It is possible to make SQL Server perform better by enabling or disabling some of them.

How to check for enabled trace flags?

The command below will show you a table with all active traces.

DBCC TRACESTATUS

How do I enable trace flags in SQL Server?

There are two ways to enable or disable them:

Using T-SQL, with the DBCC TRACE command, you have the option to set the trace flag at the session or global level.

Usually, you enable the trace flag to the entire instance (global level). For testing purposes, you may just leave it at the session level.

For example, to enable trace flag 1118 globally, you would run:

DBCC TRACEON (
		1118
		,- 1
		);

To disable it, run:

DBCC TRACEOFF (
		1118
		,- 1
		);

The use of parameter -1 turns on the flag globally.

Note: The advantage of using DBCC TRACEON and DBCC TRACEOFF is that you don’t have to restart the instance to use the trace flag. The drawback, it will not persist through a restart.

At a minimum consider using these:

  • TF3226 – This stops successful DB backup from the SQL Server error log.
  • TF1221 – Capture deadlock info to the SQL Server error log.
  • TF2389 – Manage increasing key statistics better.
  • TF2390 – Manage unknown key statistics better.
  • TF2371 – Change how AUTO_UPDATE_STATISTICS starts for large tables. Good for VLDBs. (for versions before SQL Server 2016).
  • TF1118 – Provides benefits for customers that make heavy use of the tempdb (for versions before SQL Server 2016).
  • TF3023 – Validate checksums during a backup, and generate a checksum for the entire backup. (for versions before SQL Server 2014)

Trace flags can be powerful for fine-tuning behavior, but they are only one part of a broader monitoring strategy. If your SQL Server alerting system is noisy or misconfigured, critical signals may still get lost.

We’ve written a detailed guide on SQL Server Monitoring & Alerts that explains how to reduce false positives and design alerting that focuses on what truly matters for uptime and performance.

More information

Speak with a SQL Expert

In just 30 minutes, we will show you how we can eliminate your SQL Server headaches and provide 
operational peace of mind

Article by
Mark Varnas
Founder | CEO | SQL Veteran
Hey, I'm Mark, one of the guys behind Red9. I make a living performance tuning SQL Servers and making them more stable.

Discover More

SQL Server Health Check SQL Server Migrations & Upgrades SQL Server Performance Tuning SQL Server Security SQL Server Tips

Discover what clients are saying about Red9

Red9 has incredible expertise both in SQL migration and performance tuning.

The biggest benefit has been performance gains and tuning associated with migrating to AWS and a newer version of SQL Server with Always On clustering. Red9 was integral to this process. The deep knowledge of MSSQL and combined experience of Red9 have been a huge asset during a difficult migration. Red9 found inefficient indexes and performance bottlenecks that improved latency by over 400%.

Rich Staats 5 stars
Rich Staats
Cloud Engineer
MetalToad

Always willing to go an extra mile

Working with Red9 DBAs has been a pleasure. They are great team players and have an expert knowledge of SQL Server database administration. And are always willing to go the extra mile to get the project done.
5 stars
Evelyn A.
Sr. Database Administrator

Boosts server health and efficiency for enhanced customer satisfaction

Since adding Red9 to the reporting and DataWarehousing team, Red9 has done a good job coming up to speed on our environments and helping ensure we continue to meet our customer's needs. Red9 has taken ownership of our servers ensuring they remain healthy by monitoring and tuning inefficient queries.
5 stars
Andrew F.
Datawarehousing Manager
See more testimonials