# 複合運算子 (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.
&= &= (位元 AND 指派) (Transact-SQL)&= (Bitwise AND Assignment) (Transact-SQL) 執行位元運算 AND，然後將原始值設為該結果。Performs a bitwise AND and sets the original value to the result.
^= ^= (位元排除 OR 指派) (Transact-SQL)^= (Bitwise Exclusive OR Assignment) (Transact-SQL) 執行位元排除 OR，然後將原始值設為該結果。Performs a bitwise exclusive OR and sets the original value to the result.
|=|= |= (位元 OR 指派) (Transact-SQL)|= (Bitwise OR Assignment) (Transact-SQL) 執行位元運算 OR，然後將原始值設為該結果。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;

``````