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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -