Wednesday, October 10, 2007 10:52 AM
xmldeveloper
Compound assignment operators in SQL Server 2008
If you are connected to the SQL Server blogosphere you've probably noticed lots of posts about the next version of SQL Server. One of the improvements of T-SQL is introducing the compound assignment operators (used in lots of programming languages). Most of the posts about this feature mention just the += operator. In fact SQL Server 2008 supports not just the += operator but also the following list of operators:
Subtract and assign -=
Multiply and assign *=
Divide and assign /=
Modulo and assign %=
Bitwise & and assign &=
Bitwise | and assign |=
Bitwise xor and assign ^=
Example:
DECLARE @I INT = 10;
SET @I*=10;
SELECT @I;
-- Result
100