Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger for inserting record into another table

Status
Not open for further replies.

mody82

Technical User
Jan 26, 2009
3
SA
Dear all;
I need a trigger which allow me to delete record from Table_1 and insert it to Table_2 ?
Means that I have two tables , one for current employees and the other for previous employees , So when I delete the employee from the Table_1 Should be inserted to Table_2 ...
>> Hope it's Clear <<
 
Assuming TAble_1 and Table_2 have identical structures, a simple trigger would be ...
Code:
CREATE TRIGGER trg_Table1_Delete
ON Table_1
AFTER DELETE AS 
  INSERT INTO Table_2 SELECT * FROM Deleted


--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Thx alooot , I tried it's working nicely
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top