# 复合运算符 (Transact-SQL)Compound Operators (Transact-SQL)

Transact-SQLTransact-SQL 提供了以下复合运算符：provides the following compound operators:

+= +=（加法赋值）(Transact-SQL)+= (Add Assignment) (Transact-SQL) 将原始值加上一定的量，并将原始值设置为结果。Adds some amount to the original value and sets the original value to the result.
-= -=（减法赋值）(Transact-SQL)-= (Subtract Assignment) (Transact-SQL) 将原始值减去一定的量，并将原始值设置为结果。Subtracts some amount from the original value and sets the original value to the result.
*= *=（乘法赋值）(Transact-SQL)*= (Multiply Assignment) (Transact-SQL) 将原始值乘上一定的量，并将原始值设置为结果。Multiplies by an amount and sets the original value to the result.
/= （除法赋值）(Transact-SQL)(Divide Assignment) (Transact-SQL) 将原始值除以一定的量，并将原始值设置为结果。Divides by an amount and sets the original value to the result.
%= 取模赋值 (Transact-SQL)Modulus Assignment (Transact-SQL) 将原始值除以一定的量，并将原始值设置为余数。Divides by an amount and sets the original value to the modulo.
&= &=（位与赋值）(Transact-SQL)&= (Bitwise AND Assignment) (Transact-SQL) 对原始值执行位与运算，并将原始值设置为结果。Performs a bitwise AND and sets the original value to the result.
^= ^=（位异或赋值）(Transact-SQL)^= (Bitwise Exclusive OR Assignment) (Transact-SQL) 对原始值执行位异或运算，并将原始值设置为结果。Performs a bitwise exclusive OR and sets the original value to the result.
|=|= |=（位或赋值）(Transact-SQL)|= (Bitwise OR Assignment) (Transact-SQL) 对原始值执行位或运算，并将原始值设置为结果。Performs a bitwise OR and sets the original value to the result.

## 语法Syntax

``````
expression operator expression
``````

## 参数Arguments

expressionexpression

## 示例Examples

``````DECLARE @x1 int = 27;
SET @x1 += 2 ;

DECLARE @x2 int = 27;
SET @x2 -= 2 ;
SELECT @x2 AS Subtracted_2;

DECLARE @x3 int = 27;
SET @x3 *= 2 ;
SELECT @x3 AS Multiplied_by_2;

DECLARE @x4 int = 27;
SET @x4 /= 2 ;
SELECT @x4 AS Divided_by_2;

DECLARE @x5 int = 27;
SET @x5 %= 2 ;
SELECT @x5 AS Modulo_of_27_divided_by_2;

DECLARE @x6 int = 9;
SET @x6 &= 13 ;
SELECT @x6 AS Bitwise_AND;

DECLARE @x7 int = 27;
SET @x7 ^= 2 ;
SELECT @x7 AS Bitwise_Exclusive_OR;

DECLARE @x8 int = 27;
SET @x8 |= 2 ;
SELECT @x8 AS Bitwise_OR;

``````