Blog Pages

QUOTED_IDENTIFIER

SET QUOTED_IDENTIFIER { ON | OFF }

QUOTED_IDENTIFIER is a definition that deal with quotation mark delimiting identifiers.
  • When SET QUOTED_IDENTIFIER is ON (default), identifiers can be delimited by double quotation marks, and literals must be delimited by single quotation marks. 
  • When SET QUOTED_IDENTIFIER is OFF, identifiers cannot be quoted and must follow all Transact-SQL rules for identifiers. Literals can be delimited by either single or double quotation marks.

Acording to the T-SQL ruels, literals must be delimited by single quotation marks:
Select "something"  -- error
Select 'something'  -- ok
, like when QUOTED_IDENTIFIER is ON.
But, in order to follow the ISO / SQL-92 rules regarding quotation mark delimiting identifiers and literal strings, we can set QUOTED_IDENTIFIER to OFF, and then:
Select "something"  -- ok
Select 'something'  -- ok

In the most of the cases, we will work according to the T-SQL ruels (QUOTED_IDENTIFIER ON).
We will set it to OFF when we will work agginst other systems, something that QUOTED_IDENTIFIER ON does not support or when we will replace existing systems to SQL Server, etc.

No comments:

Post a Comment