• sqlserver12345 (10/14/2013)


    ALTER PROCEDURE [dbo].[usp_Names]

    (@ID int)

    AS

    DECLARE @TaskOutFile VARCHAR(255)

    DECLARE @sqlquery VARCHAR(100) = 'select * from Table where ID=@ID';

    SET @sqlquery = REPLACE(@SQLQuery,'@ID',@ID);

    Select @TaskOutFile = 'C:\SSIS' +@ID + '.html'

    EXEC sp_makewebtask @outputfile =@TaskOutFile , @query = @sqlquery;

    Still thows an error...

    Msg 139, Level 15, State 1, Procedure usp_SurgeonProcedures, Line 0

    Cannot assign a default value to a local variable.

    Msg 137, Level 15, State 2, Procedure usp_SurgeonProcedures, Line 9

    Must declare the scalar variable "@SQLQuery".

    Msg 137, Level 15, State 2, Procedure usp_SurgeonProcedures, Line 13

    Must declare the scalar variable "@SQLQuery".

    I meant removing the quotes around the actual variable @sqlquery (which I already did in the code example).

    Not around the string.

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