sql server - SQL How to update 'Deleted' row -
when update statement entered trigger activated @ end both original , updated rows kept , can displayed if user wants to.
the orignal row's (edited marked y) values correct updated row (edited marked null) should have creationdate same orignal row's modificationdate, not creationdate. how fix it?
create trigger cloneafterupdate on processlist after update if (update(amount) or update(name)) begin insert processlisthist ( id, name, amount, creationdate, edited, modificationdate) select id, name, amount, creationdate, 'y', getdate() deleted end trigger being called when executing t-sql:
update processlist set amount = 23000 name = 'tammy' select * processlist union select * processlisthist order id asc, creationdate asc
i'm starting out sql think might it:
update processlist set amount = 23000 name = 'tammy' select ph.id, ph.name, ph.amount, ph.creationdate, ph.edited, pl.modificationdate, processlist pl left join processlisthist ph on pl.id=ph.id , pl.name= ph.name , pl.creationdate =ph.creationdate order id asc, creationdate asc this untested , give idea. if incorrect, apologize.

Comments
Post a Comment