Continuing in the series on the new features in SQL Server 2008, here is another small little tid-bit. SQL Server 2008 (tested in CTP5) supports the 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…