Error:

SELECT 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.

Fix:

Replace…

SET QUOTED_IDENTIFIER OFF
GO

with…

SET QUOTED_IDENTIFIER ON
GO

SET QUOTED_IDENTIFIER must be ON when you invoke XML data type methods.

QUOTED IDENTIFIER ON/OFF

This option specifies the setting for use of double quotes. When this is on, double quotation mark is used as part of the SQL Server identifier (object name). This can be useful in situations in which identifiers are also SQL Server reserved words.

In simple words when we have QUOTED IDENTIFIER ON, anything which is wrapped in double quotes becomes an object.

E.g.

-- The following will work
SET QUOTED_IDENTIFIER ON
GO
CREATE DATABASE "Test1"
GO
-- The following will throw an error about Incorrect syntax near 'Test2'.
SET QUOTED_IDENTIFIER OFF
GO
CREATE DATABASE "Test2"
GO

-- The following will throw an error about Invalid column name 'Column'.
SET QUOTED_IDENTIFIER ON
GO
SELECT "Column"
GO
-- The following will work
SET QUOTED_IDENTIFIER OFF
GO
SELECT "Column"
GO

Create Database

Note: By default, SET QUOTED_IDENTIFIER is set to OFF.

EXEC(‘ALTER DATABASE ‘ + @db + ‘ SET QUOTED_IDENTIFIER OFF ‘)

Reference:

Last modified: June 24, 2024

Author

Comments

Write a Reply or Comment