compound assignment operators. Here is a working example of those operators:
declare @i int
set @i = 100
/**************************
Addition and assignment
***************************/
set @i += 1
select @i
———–
101
/**************************
Subtraction and assignment
***************************/
set @i -= 1
select @i
———–
100
/**************************
Multiplication and assignment
***************************/
set @i *= 2
select @i
———–
200
/**************************
Division and assignment
***************************/
set @i /= 2
select @i
———–
100
/**************************
Addition and assignment
***************************/
set @i %= 3
select @i
———–
1
/**************************
xor operation and assignment
***************************/
set @i ^= 2
select @i
———–
3
/**************************
Bitwise & operation and assignment
***************************/
set @i &= 2
select @i
———–
2
/**************************
Bitwise | operation and assignment
***************************/
set @i |= 2
select @i
———–
2
No comments:
Post a Comment