• using cursors might not be the best option but still using cursors in this example.

    let us know if it's fine.

    DECLARE @val4 varchar(20),@val1 varchar(20),@val2 varchar(50),@val3 varchar(50),@Sql varchar(8000);

    set @val1='SQLSRV'

    set @val4=CONVERT(VARCHAR(10), GETDATE(), 101)

    Declare sample_cur cursor for

    SELECT Item_Code,Quantity

    FROM ReorderS

    OPEN sample_cur

    Fetch next from sample_cur into @val2, @val3

    While (@@fetch_status-1)

    BEGIN

    SET @Sql='Begin XXOH_INV_INTERFACE_PKG.insert_trx(''' + @val4 + ''', ''' + @val1 + ''' , '''+@val2 + ''','+@val3+'); End;'

    print @Sql

    Fetch next from sample_cur into @val2, @val3

    END

    Close sample_cur

    Deallocate sample_cur



    Pradeep Singh