As per BOL-
"Trace flags are used to temporarily set specific server characteristics or to switch off a particular behavior"
For example Trace Flags 1222 and 1204 are used to identify the deadlock information in SQL server. While trace flags 1211 and 1224 disable lock escalation in different ways.
Once we have enabled that Trace and later on we want to check the satus of that Trace. i.e. It is ON or OFF. we can do this with DBCC TRACESTATUS.
The syntax for same is as follows:
DBCC TRACESTATUS ( [ [ trace# [ ,...n ] ] [ , ] [ -1 ] ] )
[ WITH NO_INFOMSGS ]
In DBCC TRACESTATUS if you will pass the Trace numberer then you get back the status of that flag only. If you do not pass a flag number in then you get all active trace flags.
I'm not sure why -1 is there. As it doesn’t seem to do anything.
As per BOL If -1 is specified without trace#, all the global trace flags that are enabled are displayed. But I do not think this statement is true as it displays the session level flags also when we pass -1.
Let see the Result for same in SSMS:
--IF WE DO NOT PASS THE TRACE NUMBER THEN IT WILL RETURN THE STATUS FOR ALL TRACE FLAGS
DBCC TRACESTATUS()
Output:
TraceFlag Status Global Session
1204 1 0 1
1222 1 1 0
3604 1 1 0
--IF WE WILL PASS TRACE NUMBER THEN IT WILL RETURN THE STATUS ONLY FOR THAT TRACE FLAG
DBCC TRACESTATUS(1222)
Output:
TraceFlag Status Global Session
1222 1 1 0
Reference: Microsoft BOL
"Trace flags are used to temporarily set specific server characteristics or to switch off a particular behavior"
For example Trace Flags 1222 and 1204 are used to identify the deadlock information in SQL server. While trace flags 1211 and 1224 disable lock escalation in different ways.
Once we have enabled that Trace and later on we want to check the satus of that Trace. i.e. It is ON or OFF. we can do this with DBCC TRACESTATUS.
The syntax for same is as follows:
DBCC TRACESTATUS ( [ [ trace# [ ,...n ] ] [ , ] [ -1 ] ] )
[ WITH NO_INFOMSGS ]
In DBCC TRACESTATUS if you will pass the Trace numberer then you get back the status of that flag only. If you do not pass a flag number in then you get all active trace flags.
I'm not sure why -1 is there. As it doesn’t seem to do anything.
As per BOL If -1 is specified without trace#, all the global trace flags that are enabled are displayed. But I do not think this statement is true as it displays the session level flags also when we pass -1.
Let see the Result for same in SSMS:
--IF WE DO NOT PASS THE TRACE NUMBER THEN IT WILL RETURN THE STATUS FOR ALL TRACE FLAGS
DBCC TRACESTATUS()
Output:
TraceFlag Status Global Session
1204 1 0 1
1222 1 1 0
3604 1 1 0
--IF WE WILL PASS TRACE NUMBER THEN IT WILL RETURN THE STATUS ONLY FOR THAT TRACE FLAG
DBCC TRACESTATUS(1222)
Output:
TraceFlag Status Global Session
1222 1 1 0
Reference: Microsoft BOL
Thanks For Reading this Post!!