• mister.magoo (10/14/2013)


    In your version of SQL Server, you cannot use the form

    DECLARE @myvar varchar(100) = 'Some Value';

    You have to use two statements, one to DECLARE then a SET.

    DECLARE @sqlquery VARCHAR(100);

    SET @sqlquery = 'select * from Table where ID=@ID';

    Huh. I learned TSQL on SQL Server 2005, but I complete forgot you cannot assign a value to a variable while declaring it.

    Time flies by 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP