• What if you remove the quotes around @sqlquery?

    ALTER PROCEDURE [dbo].[usp_Names]

    (@ID int)

    AS

    DECLARE @TaskOutFile VARCHAR(255)

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

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

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

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

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