Update image using dynamic sql I have been battling with this statement:

ALTER PROCEDURE [dbo].[transact_image_update]
-- Add the parameters for the stored procedure here
@transact_recordID_int int, 
@image1_bin image, 
@image2_bin image, 
@transact_referenceNo_str nvarchar(25),
@userID_last uniqueidentifier,
@tableName nvarchar(50)

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here

DECLARE @sqlUpdt01 nvarchar(4000)
SET @sqlUpdt01  = '
        Update [dbo].[' + @tableName + '] SET [image1_bin] = '+ CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), @image1_bin), 2)      
        + ', [image2_bin] = '+ CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), @image2_bin), 2)
        +', [userID_last] = '''+ convert(nvarchar(4000),@userID_last)
        + ''' WHERE (transact_recordID_int = '+convert(varchar,@transact_recordID_int) +')
            AND ([transact_referenceNo_str] = ''' +convert(varchar, @transact_referenceNo_str)
             +''' )
             AND (locked_bol = 0) 
             '  
exec sp_executesql @sqlUpdt01 


Basically, I have many DB tables with similar schema but different names (for types of transactions) and would like this ONE procedure to make the update given the table name as argument.
This script compiles successfully but execution cannot update the image field.
Is there a conversion I'm missing?

Please help.
I am not sure why the procedure uses image parameters instead of varbinary(max), or why you aren't passing the parameter values to sp_executesql directly. How about:

ALTER PROCEDURE [dbo].[transact_image_update]
  @transact_recordID_int int, 
  @image1_bin varbinary(max),
  @image2_bin varbinary(max), 
  @transact_referenceNo_str nvarchar(25),
  @userID_last uniqueidentifier,
  @tableName nvarchar(50)
AS
BEGIN
  SET NOCOUNT ON;

  DECLARE @sql nvarchar(max);

  SET @sql = N'UPDATE dbo.' 
    + QUOTENAME(@tableName) + N'
    SET [image1_bin] = @i1,
            [image2_bin] = @i2,
            [userID_last] = @u
    WHERE transact_recordID_int = @t
    AND [transact_referenceNo_str] = @s
    AND locked_bol = 0;';

  EXEC sys.sp_executesql @sql,
    N'@i1 varbinary(max), @i2 varbinary(max), @u uniqueidentifier, 
    @t int, @s nvarchar(25)',
    @image1_bin, @image2_bin, @userID_last,
     @transact_recordID_int, @transact_referenceNo_str;
END