Understanding QUOTED_IDENTIFIER

前端 未结 4 969
忘掉有多难
忘掉有多难 2020-12-03 15:05

We just ran into a problem with one of our stored procs throwing an error;

SELECT failed because the following SET options have incorrect settings: \'QUOTED_         


        
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 15:37

    I saved the following command to a textfile, then executed it with SQLCMD:

    SET QUOTED_IDENTIFIER ON
    SET QUOTED_IDENTIFIER OFF
    

    Checking in SQL profiler, SQLCMD -i connects with the following connection options on my system:

    -- network protocol: LPC
    set quoted_identifier on
    ...
    

    however the following command issued by SQLCMD when it connects:

    SET QUOTED_IDENTIFIER OFF SET TEXTSIZE 4096
    

    and then it runs my script.

    So, the answer to 2) is no - running a script with SQLCMD -i is not the same as executing from SSMS (with the default connections options). If a script requires QUOTED_IDENTIFIER ON, then you need to explicitly set it at the start if you're going to execute it this way.

提交回复
热议问题