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.
- Brackets ()
- Bitwise operator ~
- Arithmetic operators *,/,%
- Arithmetic operators +,-
- Bitwise operator ^
- Bitwise Operators &
- Bitwise Operators |
- Logical operator Not\
- logical operators and
- Logical operator 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