Friday 19 April 2013

How to enable and disable trace flags, or check for active trace flags in SQL Server

Trace flags are used to temporarily set specific server characteristics or to switch off a particular behavior. Trace flags can be enabled on session level (active for a connection and are visible only to that connection) and on global level (set at the server level and are visible to every connection on the server).
Enabling and disabling trace flags on session level (you cannot enable a session-level trace flag by using a startup option):
DBCC TRACEON(trace_flag)
for example: DBCC TRACEON(3604)
DBCC TRACEOFF(trace_flag)
for example: DBCC TRACEOFF(3604)
Enabling trace flag on global level:
- adding the flag with –T switch to the startup parameters of the SQL Server Service (use an uppercase “T” to pass the trace flag number):
right-click on the SQL Server service using Configuration Manager, select Properties and the Advanced tab, and add for example:
;-T1204
to the Startup Parameters entry.

No comments:

Post a Comment