Basic object of T-SQL in SQL Server

Source: Internet
Author: User
Tags format object character set constant contains sql string variable
1, Constant
A constant is a literal and numeric, hexadecimal, or numeric constant. A string constant contains one or more characters in a single quotation mark (") or double quotation mark (" ") Character set.
If you want a separate quotation mark in a single quote-delimited string, you can use a single quotation mark (that is, a single quotation mark in two single quotes) in this character. A hexadecimal constant represents a character that is not printable or other binary data. Each hexadecimal constant starts with a 0x followed by a character or number.
Valid Word Constants Quantity Example:
"ABC"
"AB. C"
"123"
' I don ' t '
0xafec

Does not belong to the character constants quantity:
' AB ' C '--odd number of single quotes
' A '--quotes are not in pairs

A numeric constant contains all marked or unmarked integers, fixed-point values, and floating-point numbers.
The following belong to a numeric constant:
130
-130
-0.351E5

A constant usually has a data type and length, depending on the format of the constant.

2, Separator
In T-SQL, double quotes have two levels of meaning. In addition to applying strings, double quotes can also be used to make delimiters, that is, all the bounding notation (delimited identifier). A delimited identifier is a special type of identity, typically preserving the keyword as an identifier and using the name namespace of the database object.
Note: The difference between single and double quotes is that the former is used for SQL92 standards. Identifiers in this case, this standard is used to differentiate between general and separator characters. The key two points are that the delimiters are enclosed in double quotes and are case-sensitive (T-SQL also supports user square brackets ([]) to replace double quotes). Double quotes are used only for separating strings. In general, delimited identifiers illustrate the specification of identifiers and also play a role in preserving keywords. Delimited identifiers can also be made without names (identifiers, variable names) that can be used in future SQL standards for reserved keywords. Also, a delimited identifier may contain an unqualified character, such as a space, in an identifier name.
In the basic object of T-SQL, double quotes are used to define the Quote_identifier option for the SET statement. If this option is set to ON (that is, the default), the identifiers in double quotes are defined as delimiters. In this case. Double quotes cannot be used to delimit strings.

3, identifiers
In T-SQL, identifiers are used for failed database objects such as databases, tables, and indexes, represented by strings, which can be up to 128 characters long and contain letters, data, or the following characters: _, @, and #. Each name must begin with a single letter or one of the following characters: _, @, or #. #在以它开头的表明或者存储程序名表示一个临时对象. The time at the beginning of the @ represents a variable.

4, retain the key word
Each programming language has a list of reserved names that are written and used in the definition format. These names are called reserved keywords.

Related Article

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.