# 运算符优先级 (Transact-SQL)Operator Precedence (Transact-SQL)

11 ~（位非）~ (Bitwise NOT)
22 *（乘）、/（除）、%（取模）* (Multiplication), / (Division), % (Modulus)
33 +（正）、-（负）、+（加）、+（串联）、-（减）、&（位与）、^（位异或）、|（位或）+ (Positive), - (Negative), + (Addition), + (Concatenation), - (Subtraction), & (Bitwise AND), ^ (Bitwise Exclusive OR), | (Bitwise OR)
44 =、>、<、>=、<=、<>、!=、!>、!<（比较运算符）=, >, <, >=, <=, <>, !=, !>, !< (Comparison operators)
55 NOTNOT
66 AND
77 ALL、ANY、BETWEEN、IN、LIKE、OR、SOMEALL, ANY, BETWEEN, IN, LIKE, OR, SOME
88 =（赋值）= (Assignment)

``````DECLARE @MyNumber int;
SET @MyNumber = 4 - 2 + 27;
-- Evaluates to 2 + 27 which yields an expression result of 29.
SELECT @MyNumber;
``````

``````DECLARE @MyNumber int;
SET @MyNumber = 2 * 4 + 5;
-- Evaluates to 8 + 5 which yields an expression result of 13.
SELECT @MyNumber;
``````

``````DECLARE @MyNumber int;
SET @MyNumber = 2 * (4 + 5);
-- Evaluates to 2 * 9 which yields an expression result of 18.
SELECT @MyNumber;
``````

``````DECLARE @MyNumber int;
SET @MyNumber = 2 * (4 + (5 - 3) );
-- Evaluates to 2 * (4 + 2) which then evaluates to 2 * 6, and
-- yields an expression result of 12.
SELECT @MyNumber;
``````