Inline variable assignments in SQL Server 2008

 
In previous version of SQL Server, we dont have option of initialising the varaibles during declaration.
 
We have seperate parts like,
  1. Declaration part
  2. Initialisation
  3. Usage.
 
Whereas, this is bit reduced in SQL Server 2008, Declaration and initialisation can be done as a single one followed by usage one.
 
Below is a sample query to be executed in SQL Server 2008.
 

declare @val int=0, @val1 int
print @val  -- returns 0
set @val=1
print @val 
-- returns 1
 
Cheers,
Ebook Download
View all
Learn
View all