sql server - How to store record before it updated? -
i use sql server database. have 2 tables inspections , history_inspections.
before record inspections table updated, need store history_inspections table.
i wanted use sql server update trigger fired after record updated.
any idea how can store record inspections table in history_inspections table before updated ?
when after update trigger in sql server fires, inserted pseudo table inside trigger contains new values (after update), , deleted pseudo table contains old values (before update).
so in case, read out rows deleted table , store history_inspections table.
create trigger trg_afterupdateinspections on dbo.inspections after update insert dbo.history_inspections(list of columns) select (list of columns) deleted
Comments
Post a Comment