Transact-SQL syntax conventions

Source: Internet
Author: User

The following table lists and describes the conventions used in the syntax graph referenced by Transact-SQL.

Conventions Used

Uppercase

Keyword of transact-SQL.

Italics

Parameters of the User-provided Transact-SQL syntax.

Bold

Database Name, table name, column name, index name, stored procedure, utility, data type name, and text that must be displayed as is.

Underline

Indicates the default value that is applied when the clause containing the underlined value is omitted in the statement.

| (Vertical line)

Separate the syntax items in parentheses or braces. Only one of them can be used.

[] (Square brackets)

Optional. Do not enter square brackets.

{} (Braces)

Required syntax. Do not enter braces.

[,...N]

Indicates that the preceding items can be repeated.NTimes. Each item is separated by a comma.

[...N]

Indicates that the preceding items can be repeated.NTimes. Each item is separated by a space.

;

The Terminator of a Transact-SQL statement. Most SQL Server statements in this version do not require semicolons, but they need to be semicolons in future versions.

<Label >::=

The name of the syntax block. This Convention is used to group and Mark long syntax segments or syntax units that can be used in multiple positions in a statement. Each location of a syntax block can be indicated by a label enclosed in angle brackets: <tag>.

A set is a set of expressions, such as <group set> and a list is a set of expressions, for example, <list of combined elements>.

Multi-part name

Unless otherwise specified, all the transact-SQL references to the database object name will be composed of four parts, in the following format:

SERVER_NAME .[Database_name].[Schema_name].Object_name

|Database_name.[Schema_name].Object_name

|Schema_name.Object_name

| Object_name

SERVER_NAME

Specify the name of the linked server or remote server.

Database_name

If the object resides in the local instance of SQL Server, specify the name of the SQL Server database. If the object is on the linked serverDatabase_nameSpecifies the ole db directory.

Schema_name

If the object is in the SQL Server database, specify the name of the schema containing the object. If the object is on the linked serverSchema_nameThe name of the ole db architecture will be specified. For more information about the architecture, see the following table to list and describe the conventions used in the syntax graph referenced by Transact-SQL.
Conventions are used
Uppercase
Keyword of transact-SQL.

Italics
Parameters of the User-provided Transact-SQL syntax.

Bold
Database Name, table name, column name, index name, stored procedure, utility, data type name, and text that must be displayed as is.

Underline
Indicates the default value that is applied when the clause containing the underlined value is omitted in the statement.

| (Vertical line)
Separate the syntax items in parentheses or braces. Only one of them can be used.

[] (Square brackets)
Optional. Do not enter square brackets.

{} (Braces)
Required syntax. Do not enter braces.

[,... N]
Indicates that the previous item can be repeated n times. Each item is separated by a comma.

[... N]
Indicates that the previous item can be repeated n times. Each item is separated by a space.

;
The Terminator of a Transact-SQL statement. Most SQL Server statements in this version do not require semicolons, but they need to be semicolons in future versions.

: =
The name of the syntax block. This Convention is used to group and Mark long syntax segments or syntax units that can be used in multiple positions in a statement. Each location of a syntax block can be indicated by a label enclosed in angle brackets: <tag>.
A set is a set of expressions, such as <group set> and a list is a set of expressions, for example, <list of combined elements>.

Multi-part name
Unless otherwise specified, all the transact-SQL references to the database object name will be composed of four parts, in the following format:
SERVER_NAME. [database_name]. [Schema_name]. object_name
| Database_name. [Schema_name]. object_name
| Schema_name.object_name
| Object_name
SERVER_NAME specifies the name of the linked server or remote server.
Database_name: Specifies the name of the SQL Server database if the object resides in the local instance of SQL Server. If the object is on the linked server, database_name specifies the ole db directory.
Schema_name if the object is in the SQL Server database, it specifies the name of the schema containing the object. If the object is on the linked server, Schema_name specifies the ole db schema name. For more information about architectures, see architecture separation.
The name of the object_name object.
When referencing a specific object, you do not always need to specify the server, database, and architecture for the SQL Server database engine to identify the object. However, if the object cannot be found, an error message is returned.
Note:
To avoid name resolution errors, we recommend that you specify the schema name if you specify an object within the schema range.

To omit intermediate nodes, use periods to indicate these locations. The following table shows the valid format of the Object Name.
Object reference format description
Server. database. schema. Object
The name of the four parts.

Server. database... object
The schema name is omitted.

Server.. schema. Object
The database name is omitted.

Server... object
The name of the database and architecture is omitted.

Database. schema. Object
The server name is omitted.

Database.. Object
The name of the server and architecture is omitted.

Schema. Object
The server and database names are omitted.

Object
The name of the server, database, and architecture is omitted.

CodeSample conventions
Unless otherwise specified, the examples provided in the transact-SQL reference have been tested using the default settings of SQL Server Management Studio and the following options:
Ansi_nulls
Ansi_null_dflt_on
Ansi_padding
Ansi_warnings
Concat_null_yields_null
Quoted_identifier
Most code examples in the transact-SQL reference have been tested on servers running case-sensitive sorting order. The test server usually runs the ANSI/ISO 1252 code page.
Many code examples use letter N as the prefix of Unicode string constants. If there is no N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters. For more information, see server-side programming with Unicode.

Object_name

Object Name.

When referencing a specific object, you do not always need to specify the server, database, and architecture for the SQL Server database engine to identify the object. However, if the object cannot be found, an error message is returned.

Note:
To avoid name resolution errors, we recommend that you specify the schema name if you specify an object within the schema range.

To omit intermediate nodes, use periods to indicate these locations. The following table shows the valid format of the Object Name.

Object reference format Description

Server . Database . Schema . Object

The name of the four parts.

Server . Database .. Object

The schema name is omitted.

Server .. Schema . Object

The database name is omitted.

Server ... Object

The name of the database and architecture is omitted.

Database . Schema . Object

The server name is omitted.

Database .. Object

The name of the server and architecture is omitted.

Schema . Object

The server and database names are omitted.

Object

The name of the server, database, and architecture is omitted.

Sample Code Convention

Unless otherwise specified, the examples provided in the transact-SQL reference have been tested using the default settings of SQL Server Management Studio and the following options:

    • Ansi_nulls
    • Ansi_null_dflt_on
    • Ansi_padding
    • Ansi_warnings
    • Concat_null_yields_null
    • Quoted_identifier

Most code examples in the transact-SQL reference have been tested on servers running case-sensitive sorting order. The test server usually runs the ANSI/ISO 1252 code page.

Many code examples use lettersNIt is the prefix of a unicode String constant. If noNThe default code page of the database. This default code page may not recognize certain characters. For more information, see the following table to list and describe the conventions used in the syntax graph referenced by Transact-SQL.
Conventions are used
Uppercase
Keyword of transact-SQL.

Italics
Parameters of the User-provided Transact-SQL syntax.

Bold
Database Name, table name, column name, index name, stored procedure, utility, data type name, and text that must be displayed as is.

Underline
Indicates the default value that is applied when the clause containing the underlined value is omitted in the statement.

| (Vertical line)
Separate the syntax items in parentheses or braces. Only one of them can be used.

[] (Square brackets)
Optional. Do not enter square brackets.

{} (Braces)
Required syntax. Do not enter braces.

[,... N]
Indicates that the previous item can be repeated n times. Each item is separated by a comma.

[... N]
Indicates that the previous item can be repeated n times. Each item is separated by a space.

;
The Terminator of a Transact-SQL statement. Most SQL Server statements in this version do not require semicolons, but they need to be semicolons in future versions.

: =
The name of the syntax block. This Convention is used to group and Mark long syntax segments or syntax units that can be used in multiple positions in a statement. Each location of a syntax block can be indicated by a label enclosed in angle brackets: <tag>.
A set is a set of expressions, such as <group set> and a list is a set of expressions, for example, <list of combined elements>.

Multi-part name
Unless otherwise specified, all the transact-SQL references to the database object name will be composed of four parts, in the following format:
SERVER_NAME. [database_name]. [Schema_name]. object_name
| Database_name. [Schema_name]. object_name
| Schema_name.object_name
| Object_name
SERVER_NAME specifies the name of the linked server or remote server.
Database_name: Specifies the name of the SQL Server database if the object resides in the local instance of SQL Server. If the object is on the linked server, database_name specifies the ole db directory.
Schema_name if the object is in the SQL Server database, it specifies the name of the schema containing the object. If the object is on the linked server, Schema_name specifies the ole db schema name. For more information about architectures, see architecture separation.
The name of the object_name object.
When referencing a specific object, you do not always need to specify the server, database, and architecture for the SQL Server database engine to identify the object. However, if the object cannot be found, an error message is returned.
Note:
To avoid name resolution errors, we recommend that you specify the schema name if you specify an object within the schema range.

To omit intermediate nodes, use periods to indicate these locations. The following table shows the valid format of the Object Name.
Object reference format description
Server. database. schema. Object
The name of the four parts.

Server. database... object
The schema name is omitted.

Server.. schema. Object
The database name is omitted.

Server... object
The name of the database and architecture is omitted.

Database. schema. Object
The server name is omitted.

Database.. Object
The name of the server and architecture is omitted.

Schema. Object
The server and database names are omitted.

Object
The name of the server, database, and architecture is omitted.

Sample Code Convention
Unless otherwise specified, the examples provided in the transact-SQL reference have been tested using the default settings of SQL Server Management Studio and the following options:
Ansi_nulls
Ansi_null_dflt_on
Ansi_padding
Ansi_warnings
Concat_null_yields_null
Quoted_identifier
Most code examples in the transact-SQL reference have been tested on servers running case-sensitive sorting order. The test server usually runs the ANSI/ISO 1252 code page.
Many code examples use letter N as the prefix of Unicode string constants. If there is no N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters. For more information, see server-side programming with Unicode.
Reference source http://msdn.microsoft.com/zh-cn/library/ms177563.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.