QUOTED IDENTIFIER error in SQL Server 2008 on SP execution

611 views Asked by At

I have this error on executing stored procedure:

INSERT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.

Procedure is created with QUOTED_IDENTIFIER flag set to ON

IF EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'sp_procedure') AND TYPE IN (N'P', N'PC'))
  BEGIN
    DROP PROCEDURE  [dbo].[sp_procedure]
  END
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[sp_procedure]
(   
     @param_1 XML
    ,@param_2 INT
)
AS
BEGIN
   -- CODE
END

SELECT statement from sys.sql_modules shows that uses_quoted_identifiers somehow is set to 0.

I have already tried to execute following code. It run in one batch.

SET QUOTED_IDENTIFIER ON; 
EXEC sp_procedure @param_1 = N'<?xml version="1.0" encoding="utf-16"?>
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" />', @param_2= 51326

But it does not help.

Each session is created with QUOTED_IDENTIFIER set to 1:

set quoted_identifier on 
set arithabort off 
set numeric_roundabort off
set ansi_warnings on

Any ideas what can it be?

UPD Turned out that after running this specific script, there also run lots of other files. And one of them just recreated stored procedure with QUOTED_IDENTIFIER set to OFF.

Thank you for your help

1

There are 1 answers

0
Thomas Kejser On

Pleasure make sure the table and view definitions are also created with quoted identifier on.