Basic Object for T-SQL in SQLServer

Source: Internet
Author: User
Tags printable characters
The basic objects of SQL mainly include constants, delimiters, and reserved keywords.

The basic objects of SQL mainly include constants, delimiters, and reserved keywords.

1. Constants
A constant is a hexadecimal or numeric constant that contains text and numbers. A String constant contains one or more characters in the single quotation mark ('') or double quotation mark (" ") Character Set.
If you want to use a separate pair of quotes in a single-quotation-separated string, you can use a single pair of consecutive single quotes in this character (that is, two single quotes are used to represent single quotes ). A hexadecimal constant represents non-printable characters or other binary data. Each hexadecimal constant starts with 0x and is followed by a character or number.
Examples of valid character constants:
"AB. c"
'I don't'
0 xafec

Not a character constant:
'AB' C' -- an odd number of single quotes
'A "-- the quotation marks are not paired.

A numeric constant contains all integers, fixed-point values, and floating-point numbers with or without signs.
The following are numerical constants:

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

2. delimiter
In the T-SQL, double quotes have two meanings. In addition to strings, double quotation marks can also be used as separators, that is, all delimited identifier ). Delimiter identifiers are a special type of identifiers. They usually use reserved keywords as identifiers and use the namespace of the database object.
Note: The difference between single quotes and double quotes is that the former is used for the SQL92 standard. In this case, the standard is used to distinguish between regular and delimiter. The key two points are that the separator is enclosed by double quotation marks and is case sensitive (the T-SQL also supports user square brackets ([]) instead of double quotation marks ). Double quotation marks are only used to separate strings. In general, delimiter identifiers indicate the specifications of identifiers, and play the same role in retaining keywords. Separated identifiers can also be used as reserved keywords in future SQL standards without names (identifiers and variable names. In addition, delimiter identifiers may contain unspecified characters, such as spaces, in the identifiers.
In the basic object of the T-SQL, using double quotes is the QUOTE_IDENTIFIER option that defines the SET statement. If this option is set to ON (default), the identifier in double quotation marks is defined as a separator. In this case. Double quotation marks cannot be used to separate strings.

3. identifier
In the T-SQL, the identifier is used for failed database objects such as databases, tables, and indexes, represented by strings, can be up to 128 characters in length, also contains letters, data, or the following characters: _, @, and #. Each name must start with a letter or a character below: _, @, or #. # A representation starting with it or a bucket name represents a temporary object. The time starting with @ indicates a variable.

4. reserved keywords
Each programming language has a series 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: 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.