MS SQL Basics Tutorial: Annotation characters, operators, and wildcard characters

Source: Internet
Author: User
Tags arithmetic arithmetic operators bitwise logical operators

4.5.1 annotation character (Annotation)

Two types of annotation characters can be used in Transact-SQL.

The ANSI standard annotation character "--" is used for single-line annotations;

The same as the C language of the program annotation symbol, that is, "/**/". "/*" is used for the beginning of the annotation text, "*/" for the end of the comment text, you can identify multiple lines of text in the program as comments.

4.5.2 operator (Operator)

1 Arithmetic operators

Includes: + (plus),-(minus), (multiply), (except),% (take more)

2 comparison operators

Includes:> (greater than) < (less than), = (equals), >= (greater than or equal), <= (less than equal), <>

(Not equal to),!= (not equal to),!> (not greater than)!< (not less than)

Where!=,!>,!< are not ANSI-standard operators.

3 logical operators

Include: and (with), or (or), not (non)

4-bit operator

Includes: Bitwise AND, | (bitwise OR), ~ (bitwise NOT) ^ (bitwise XOR)

5 Connection Operators

The join operator "+" is used to concatenate a mixture of two or more characters or binary strings, column names, or strings and columns, adding a string to the end of another string. The syntax is as follows:

<expression1>+<expression2>

Example 4-7

Use Pangu

Declare@startdate datetime

Set@startdate= ' 1/1/2000 '

Select ' Start Date: ' +convert (varchar @startdate)

The--convert () function is used to convert the data type, see 4.8.4

The results of the operation are as follows:

Start Date:jan 1 2000

Example 4-8:

Use Pangu

Select ' The highest salary of the employee is: ' + e_name+ ' monthly salary: ' +convert (varchar) e_wage

From employee

where e_wage=

(select Max (e_wage)

From employee)

The results of the operation are as follows:

The employee with the highest monthly salary is: John Monthly salary is 8000.00

(1 row (s) affected)

In Transact-SQL, operators are processed in the following order, if the same-level operations appear together, the order bits are processed from left to right.

bracket () bitwise operator ~ arithmetic operator *,/,% arithmetic operator +,-bitwise operator ^ bit operator & Bitwise operator | Logical operators not logical operators and logical operators OR

4.5.3 wildcard character wildcard

You can use the wildcard characters shown in table 4-4 in SQL Server.

Table 4-4 Transact-SQL wildcard characters

See the full set of "MS SQL Basics Tutorials"

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.