DataSentinel

DataSentinel

Saturday, November 27, 2010

One cool feature that I have come across and now use is the Compound Assignment Operators in 2008. This new feature allows the combining of operators. So for example:

Declare@i integer = 5,
Set @i += 6 – Add and Assign
Select @i as [new value]

As you can see you can do the adding and assigning all on 1 line!… I don’t know about you but sometimes I go blind looking through tons of lines of code. Another cool feature in 2008 is the ability now to declare AND initialize variables within the same line of code!… so for example:

Declare@i as Integer = 0,
@d as datetime = current_timestamp

Select @i as [i], @d as [d]

I hope these little nuggets in 2008 will assist you in simplifying your code and to see another reason to move your database servers to 2008. Stay tuned because I will be covering other new areas in 2008 and posting tips and tricks from the field!…

No comments: