Lynn Pettis (6/24/2010)
SanjayAttray (6/24/2010)
Even though I got it right and know its possible but when executed in SSMS 2005 it returned error.Msg 139, Level 15, State 1, Line 0
Cannot assign a default value to a local variable.
Msg 139, Level 15, State 1, Line 0
Cannot assign a default value to a local variable.
Msg 137, Level 15, State 2, Line 3
Must declare the scalar variable "@a".
Code provided in the question is using SQL Server 2008 syntax, that's why it didn't work for you in SQL Server 2005 SSMS.
It's surprising how quickly I have come to use SQL 2008 syntax - if I'd written that just a few weeks earlier it would have been in SQL 2000 syntax (so it would have worked in 2000, 2005, and 2008).
Tom