Identifiers (DMX)

All objects in Microsoft SQL Server Analysis Services must have an identifier. Servers, databases, and database objects such as data sources, data source views, cubes, dimensions, mining models, and so on all have identifiers.

An object identifier is created when you define the object. The object's name is its identifier. You then use the identifier to reference the object.

There are two classes of identifiers in Data Mining Extensions (DMX):

  • Regular identifiers

  • Delimited identifiers

Regardless of the identifier type, identifiers must be 100 characters or less.

Regular Identifiers

Regular identifiers are names that comply with the Analysis Services rules for the format of identifiers. In DMX, regular identifiers do not require delimiters. The following is an example of a DMX statement that uses a regular, non-delimited identifier:

SELECT * FROM Clustering.CONTENT

In this example, "Clustering" is the name of the mining model, and also its identifier. Because the identifier does not contain any spaces or other special characters, it is a regular identifier and does not need to be enclosed in brackets.

Rules for Regular Identifiers

Following are the rules for the format of regular identifiers:

  1. The first character of a regular identifier must be one of the following:

    • A letter as defined by the Unicode Standard 2.0. This includes Latin characters from a through z and from A through Z, and letter characters from other languages.

    • An underscore (_).

  2. Subsequent characters can be:

    • Letters as defined in the Unicode Standard 2.0.

    • Decimal numbers from either Basic Latin or other national scripts.

    • An underscore (_).

  3. The identifier must not be a DMX reserved word. Reserved words are case-insensitive in DMX. For more information, see Reserved Keywords (DMX).

  4. The identifier cannot contain embedded spaces or special characters.

If an identifier does not comply with these rules, you must enclose the identifier in square brackets when you use the identifier in DMX statements.

Delimited Identifiers

Delimited identifiers are identifiers that are enclosed in brackets ([ ]). Following is an example of a DMX statement with a delimited identifier.

SELECT * FROM [Marketing_Clusters].CONTENT

In this example, the identifier for the mining model is [Marketing_Clusters]. The name has been enclosed in brackets even though it meets the criteria for regular identifiers. Many people consider it a good practice to use brackets for identifiers for clarity and to minimize problems with code maintenance and migration, even when brackets are not required.

Any identifier that does not comply with the rules for the format of regular identifiers must always be delimited. Following is an example of DMX statement with a delimited identifier that contains a space:

SELECT * FROM [Targeted Mailing].CONTENT

You must always use delimited identifiers in the following situations:

  • When you use reserved words for object names or parts of object names.

    We recommend that you do not use reserved keywords as object names. Databases that you upgrade from earlier versions of Analysis Services may contain identifiers that include words that were not reserved in the earlier version of Analysis Services but that are reserved keywords in subsequent versions. You can use a delimited identifier to refer to such an object until you can change the object's name.

  • When you use characters that are not defined in the rules for normal identifiers.

    In Analysis Services you can use any character in the current code page in a delimited identifier; however, use of special characters in an object name may make DMX statements difficult to read and maintain. For example, if some client applications cannot use the code page, users of that application may not be able to view the special characters. As a best practice, you should use identifiers that can be read and entered from any client that you or your users may need to use.

    Note

    When you upgrade an Analysis Services database to SQL Server 2008 from a previous version, some object names might be modified to preserve uniqueness. For more information, see Breaking Changes to Analysis Services Features in SQL Server 2008.

Rules for Delimited Identifiers

Following are the rules for the format of delimited identifiers:

  1. Delimited identifiers can contain the same number of characters as regular identifiers: from 1 through 100 characters, not including the delimiter characters.

  2. The body of an identifier can contain any combination of characters that are used in the current code page, including the delimiting characters themselves. If the body of the identifier itself contains delimiting characters, special handling is required:

    • If the body of the identifier contains a left bracket ([), no additional handling is required.

    • If the body of the identifier contains a right bracket (]), you must specify two right brackets (]]) to represent a single right bracket within the identifier.

Delimiting Identifiers with Multiple Parts

When you use qualified object names, you may have to delimit more than one of the identifiers that make up the object name. You must delimit each identifier individually. The following example shows a qualified object name that contains multiple delimited identifiers.

[AdventureWorks DW 2008].[Targeted Mailing DT]