sql - How to create a trigger that copies into another table the original and edited data from a table? -
i using sql server , wondering if there way create trigger on table allows copy original data before update , copy modified data after update in table?
if yes, how make difference between both?
thanks :)
@sourava
create trigger somebeforeupdatetrigger on yourtable before update insert secondtable (id, name) select id, name deleted; go insert secondtable (id, newname) select id, name inserted;
if understand correctly, yes possible. need before update
trigger.
create trigger somebeforeupdatetrigger on yourtable before update insert beforeupdate (id, name) select id, name deleted; go insert afterupdate (id, name) select id, name inserted;
the first statement insert rows table beforeupdate
getting changed. second insert new rows table afterupdate
.
Comments
Post a Comment