• Prasune Verma (5/11/2012)


    I got the answer right but only after removing 'Null' from the declaration of the Local Variable.

    So I guess you are running SQL Server 2005 or older?

    The ability to assign a value to a variable on the DECLARE statement (as used in the QotD) was added in SQL Server 2008.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/