• Minnu (11/25/2015)


    without "old_val, new_val" trigger is working fine,want to add the old and new values to know which value is udpated to what.

    please help in query.

    Maybe this code could solve your problem

    if update (val1) or update(val2)

    begin

    insert into ch_track (id,action,field_name, datetime_1,user_name,old_val, new_val)

    select ch.id,'u',@columns_updated,getdate(),'lcc001' from ch_track ch

    inner join inserted i on ch.id=i.id

    update ch_track

    set old_val = d.old_val

    from ch_track ch

    inner join deleted d on ch.id=d.id

    end

    Igor Micev,My blog: www.igormicev.com