SQL SERVER – 2008 – Inline Variable Assignment

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.

---- 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

SQL SERVER - 2008 - Inline Variable Assignment inlinevar

Reference : Pinal Dave (https://blog.sqlauthority.com)

SQL Scripts
Previous Post
SQLAuthority News – 600 Article and Over 3 Million Readers
Next Post
SQL SERVER – Introduction to SERVERPROPERTY and example

Related Posts

Leave a Reply