The quoted identifier enhancement configuration parameter allows Adaptive Server to use quoted identifiers for:
Tables
Views
Column names
Index names (Adaptive Server version 15.7 and later)
System procedure parameters (Adaptive Server version 15.7 and later)
quoted identifier enhancement is part of the enable functionality group, and its default settings depends on the settings for enable functionality group configuration parameter. See the System Administration Guide, Volume 1. To enable quoted identifiers:
Set the enable functionality group or quoted identifier enhancement configuration parameter to 1. For example:
sp_configure "enable functionality group", 1
You must restart Adaptive Server for the change to take effect.
Turn on quoted_identifier for the current session:
set quoted_identifier on
Once you enable quoted identifier enhancement, the
query processor removes delimiters and trailing spaces from object
definitions when you include quoted identifiers. For example, Adaptive
Server considers "ident"
, [ident]
,
and ident
to be identical.
If quoted identifier enhancement is not enabled, "ident"
is
considered distinct from the other two.
When you start Adaptive Server with quoted identifier enhancement enabled:
Objects you create with quoted identifiers before restarting Adaptive Server with the enable functionality group configuration parameter enabled are not automatically accessible when you use quoted identifiers after starting the server with this parameter enabled, and vice versa. That is, Adaptive Server does not automatically rename all database objects.
However, you can use sp_rename to
manually rename objects. For example, if you create an object named "ident"
and
then restart Adaptive Server with enable functionality
group enabled, rename the object by issuing:
sp_rename '"ident"', 'ident'
Adaptive Server treats [tab.dba.ident]
and "tab.dba.ident"
as fully
qualified names.
Any Transact-SQL statements, functions, and system or stored procedures that accept identifiers for objects also work with delimited identifiers.
The valid_name function distinguishes strings that are valid for identifiers under regular rules from those that are valid under the rules for delimited identifiers, with a nonzero return indicating a valid name.
For example, valid_name('ident/v1')
returns
true (zero) since 'ident/v1'
is
valid only as a delimited identifier. However, valid_name('ident')
returns
a nonzero value because 'ident'
is
valid as a delimited identifier or as a normal identifier.
Identifiers are limited to 253 characters (28 bytes) (without quoted identifier enhancement enabled these are 255 characters (30 bytes) long). Valid lengths for delimited identifiers include the delimiters and any embedded or trailing spaces.
Sybase recommends that you avoid conventional identifiers that cannot be represented as delimited identifiers zones (254–255 or 29–30 bytes in length). Adaptive Server and its subsystems occasionally construct internal SQL statements with delimiters added to identifiers.
Sybase recommends that you do not use dots and delimiters as part of identifiers because of how Adaptive Server interprets double quotes in varchar strings referring to identifiers.
Identifiers have these additional constraints if they relate to items outside Adaptive Server:
Identifiers must begin with an alphabetic character followed by alphanumeric characters or several special characters ($, #, @, _, ¥, £). Additionally:
SQL variables can include @ as the first character.
Temporary objects (objects in tempdb) can include # as the first character.
You cannot use reserved words as identifiers. See Chapter 5, “Reserved Words.”
Delimited identifiers need not conform to the rules for conventional identifiers, but must be delimited with matching square brackets or with double quotes.
You cannot use delimited identifiers for variables or labels.
You must enable set quoted_identifier to use quoted identifiers. Once you enable set quoted_identifier, you must enclose varchar string literals in single, not double, quotes.
varchar string literals that contain identifiers cannot include delimiter characters.
Delimited identifiers cannot begin with the pound-sign (#). Sybase also recommends that they do not:
Begin with (@)
Include spaces
Contain the dot character (.), or the delimiter characters: “, [, or ]
Trailing spaces are stripped from delimited identifiers, and zero-length identifiers are not allowed.