|
Question : Magic Table
|
|
we have two magic tables
Table A having delete purpose Table B having inserting purpose
But my proublem is update both table. Know i am using Update Trigger.
Can u any body explain me Architure of How update Trigger will work
|
|
Answer : Magic Table
|
|
Ok what i understand from your question is that..you created two tables one is DELETED and other is INSERTED. when ever your table is updated the OLD record (which will be deleted) should be placed i the DELETED table. and the new record (which is inserted) should be entered into INSERTED table. If this what you asking. it should be similar to the one below
CREATE TRIGGER updHistoryData ON HistoryTab FOR update AS IF (COLUMNS_UPDATED() & 6) > 0 BEGIN INSERT INTO DeletedTable SELECT 'OLD', del.Date, del.[Name], del.Address FROM deleted del -- Audit NEW record. INSERT INTO InsertedTable SELECT 'NEW', ins.Date, ins.[Name], ins.Address FROM inserted ins END
when ever you update a column in you table. the trigger will execute two insert statements as above. the deleted table will get the previous value of the updated column and the insertedtable will get teh new value of teh updated column. i think this what you meant by architecture
|
|
|
|