I loved this feature. I have always wanted this feature to be present in SQL Server. Last time when I met developers from Microsoft SQL Server, I had talked about this feature. I think this feature saves some time but make the code more readable. Inline variable assignment lets you declare a variable and set its value in one line.
---- SQL Server 2005 Way
DECLARE @MyVar INT
SET @MyVar = 5
SELECT @MyVar AS TestVar
GO
---- SQL Server 2008 Way
DECLARE @MyVar INT = 5
SELECT @MyVar AS TestVar
GO

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.




