== Why is this an issue? SQL Server can be tuned at ``++PROCEDURE++`` and ``++TRIGGER++`` levels thanks to several ``++SET++`` statements that change the current session handling of specific information. This rule raises an issue when expected configuration is not set or is set with an unexpected value between the beginning of the ``++PROCEDURE++`` (or ``++TRIGGER++``) definition and the first statement that is not a ``++SET++``, ``++IF++`` or ``++DECLARE++``. === Noncompliant code example When this rule is configured with ARITHABORT and ON. [source,sql] ---- CREATE PROCEDURE dbo.MyProc AS BEGIN SET ARITHABORT OFF; -- Noncompliant; ARITHABORT is OFF SELECT COUNT(*) FROM MY_TABLE END; ---- [source,sql] ---- ALTER PROCEDURE dbo.MyProc AS BEGIN SELECT COUNT(*) FROM MY_TABLE SET ARITHABORT ON; -- Noncompliant; ARITHABORT is not set at the beginning of the procedure definition [...] END; ---- [source,sql] ---- CREATE PROCEDURE dbo.MyProc AS BEGIN -- Noncompliant; ARITHABORT is not set at all, so default value of SQL Server will be applied SELECT COUNT(*) FROM MY_TABLE END; ---- === Compliant solution [source,sql] ---- CREATE PROCEDURE dbo.MyProc(@setConfig INT) AS BEGIN IF @setConfig=1 BEGIN SET ARITHABORT ON; END SELECT COUNT(*) FROM MY_TABLE END; ---- [source,sql] ---- ALTER PROCEDURE dbo.MyProc AS BEGIN DECLARE @var INT; SET ARITHABORT ON; [...] END; ---- == Resources * https://docs.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql?view=sql-server-2017[SET Statements] - SQL Server (Transact-SQL) Documentation ifdef::env-github,rspecator-view[] ''' == Implementation Specification (visible only on this page) === Message \[Add|Set] configuration "xxx" with expected value "yyy". === Parameters .configuration identifier **** identifier of the parameter to configure **** .value **** value expected for the parameter **** endif::env-github,rspecator-view[]