In Sql 2008 (Katmai), a couple of the 'smaller' features that are currently in the latest CTP include inline variable initialization and compound assignment (something you App Dev folks have had for years). So, the following types of code now work in Sql 2008:
declare @d datetime = getdate(),
@i int = 1,
@s varchar(100) = 'test';
— Show the values…
select @d, @i, @s
— Increment i, append to s…
select @i += 1, @s += 'ing';
— Show the new values…
select @i, @s;
These operators also work inline with DML statements and columns…for example, a simple UPDATE statement in a table called 'testTable' with a column called 'testColumn' where you wanted to increment the value of testColumn by 1 could be:
update testTable set testColumn += 1;
Also would work with other columns…if another column called testColumn2 existed:
update testTable set testColumn += testColumn2;
I'll be posting other tidbits in Sql 2008 ongoing…enjoy!

Chad is an Architect, Administrator, and Developer with technologies such as Sql Server (and related technologies), .NET, Windows Server, and the Microsoft Clustering stack (MSCS, NLB, HPC). After nearly 5 years at Microsoft in a variety of roles related to pushing the limits of the Microsoft stack in many of the largest, most complex Sql Server installations in the world, he now provides consulting to many different customers and clients ranging from startup to Fortune 50. Most recently he has been spending much of his time as an architect at SpruceMedia, Inc., a startup firm in the Facebook/Social Advertising space (http://sprucemedia.com) and resides in the Redmond, WA area where he also spends a significant amount of time writing, talking, presenting and blogging about the data-related technologies on the Microsoft stack. Chad regularly posts Sql Server related content, tools, and advice with the MSSQLTips team and on stackoverflow.com at http://stackoverflow.com/users/169012/chadhoc. Chad can be contacted via email at chad dot boyd dot tips at gmail dot com.


