SQL Server 2008 Calculation Variables

January 19, 2011

SqlServer 2008 has a short hand/compact way of assigning calculation variables.

e.g

Sql2005

DECLARE @val INT
set @val = 1;
set @val = @val + 1;

Sql2008

DECLARE @val INT
set @val = 1;
set @val += 1;

Same applies to other operators, *=, –=, /=