• Hi,

    You can use joins in update queries much like you could in a select. This should solve your issue. Also, please post using the (code) forum formatting shortcuts so that things like table data appear in fixed-width font as it's much easier to read...

    Anyhow,

    update TIEWF

    Set TIEWF.Status = W.cod_Status,

    TIEWF.Approver = W.cod_approver

    from #tmpIEWorkflow TIEWF

    inner join IEWorkflow W

    on TIEWF.IExpenseID = W.IExpenseID

    and TIEWF.num_Lev = W.num_lev

    and W.num_seq = 10

    and W.cod_status not in ('FWD', 'AWB', 'FDB')

    Where TIEWF.Status = 'FWD'

    If multiple rows in W match up with TIEWF then you could have the update happening multiple times which isn't really predicable. If this is the case then instead of joining directly to IEWorkflow you could join to a subquery that selects the most appropriate rows form IEWorkflow instead.