SET ANSI_WARNINGS OFF should not used in stored procedures or indexed views

A good rule suggestion:

  • If SET ANSI_WARNINGS OFF is used on the Beginn of a procedure DML statements to tables with computed columns, which contains an index on there going to be fail: https://nocolumnname.blog/tag/index/

  • snippet of Noncompliant Code:
    CREATE PROCEDURE [name]
    AS
    BEGIN

    SET ANSI_WARNINGS OFF

    [Furter code]

    End

  • Snippet of Compilant Code
    CREATE PROCEDURE [name]
    AS
    BEGIN

    [Further code]

    END

  • external references and/or language specifications: https://nocolumnname.blog/tag/index

  • type : Bug, Code Smell

Hello,

Sorry for the late reply.
Thanks for the suggestion. I agree that it would make sense to have such a rule.
I’ve created a ticket for this: SONARTSQL-240.

Best,
-Chris

1 Like