INSERT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'

前端 未结 4 963
遥遥无期
遥遥无期 2021-02-11 18:24

We are getting the below message sometimes while executing the stored procedure, after that without any change deleting and re-executing the stored procedure it is working fine.

相关标签:
4条回答
  • 2021-02-11 19:10

    QUOTED_IDENTIFIER is a "sticky" option so the setting in effect when the procedure was created is used at runtime. Since no procedure changes were made, the error suggests the stored procedure was created with QUOTED_IDENTIFIER OFF and an index with one of the types mentioned in the error message was created/dropped.

    Recreate or alter the stored procedure from a session with both QUOTED_IDENTIFIER ON and ANSI_NULLS ON to avoid the problem going forward.

    0 讨论(0)
  • 2021-02-11 19:14

    In my case I had to add -I parameter to sqlcmd.exe command line when loading stored procedures in the bulk mode.

    0 讨论(0)
  • 2021-02-11 19:26

    I was running into this problem so I created all my Job's Steps into Stored procedures in MS SQL. When using the template it automatically has the following

    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_NULLS ON
    
    0 讨论(0)
  • 2021-02-11 19:31

    If anyone hits this error after having deployed via a Visual Studio database project then it's worth checking the properties of your stored procedure file. If this is set to Project Default then go to the properties of your database project > Project Settings and click the Database Setting button.

    You can turn these two values (and others) to be on by default as shown in the screenshot below.

    This will only fix the issue if you have changes to the procedure how ever; a schema compare and subsequent update will not change the QUOTED_IDENTIFIER in the stored procedure unless there are changes to the body of the procedure. It will prevent the problem from reoccurring on a subsequent schema updated though.

    0 讨论(0)
提交回复
热议问题