You can enable or disable trace flag at the session level for analyzing something, or at the server level for all connections. In this blog, we shall see how to enable or disable trace flags in SQL Server on Linux for the startup of the SQL Server service so that it can be used globally.
Enable Trace Flags
- Connect your Linux machine as a root user
Syntax: sudo -i
- Let’s connect to SQL Server Linux Instance using SSMS and get all the default enabled trace flags.
- Enable a trace flag by running below command. For example, I am going to enable trace flag 3604.
Syntax: /opt/mssql/bin/mssql-conf traceflag <traceflagNumber1> on
- You can enable multiple trace flags by specifying them separately. For example, I am going to enable trace flag 1118 and 1117 in one shot.
Syntax: /opt/mssql/bin/mssql-conf traceflag <traceflagNumber1> <traceflagNumber2>on
- Once you enable the global trace flag, It will ask you restart the SQL Server service
Syntax: systemctl restart mssql-server
- Check out all enabled global trace flags
You can see the trace flags 3604, 1117 and 1118 are enabled globally now.
Disable Trace Flags
- You can disable one or more enabled trace flags in one attempt by specifying them. For example, I am going to disable trace flag 3604, 1118 and 1117 in one attempt.
Syntax: /opt/mssql/bin/mssql-conf traceflag 3604 1118 1117 off
- Once you disable the global trace flag, It will ask you restart the SQL Server service
Syntax: systemctl restart mssql-server
- Verify the disabled trace flags are still active or not.
Now, we cannot see the disabled trace flags 3604, 1117 and 1118. It means the trace flag are no more active on the server. Please do comment, if you have any question regarding trace flag on SQL Server on Linux