Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Trigger for inserting record to another table

Author  Topic 

mody82
Starting Member

13 Posts

Posted - 2009-01-26 : 09:22:55
Dear All

I need a Trigger that will delete a record from one table and insert it to another table , in outher meaning >> I have two tables T1 and T2 , T1 contains new Employee and T2 contains Old Employees , So when I delete an old employee from the T1 table it should be insert it in the T2 table

>> Hope that it's clear <<

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-26 : 09:25:53
[code]CREATE TRIGGER CaptureOldEmp
ON T1
AFTER DELETE
AS
BEGIN
INSERT INTO T2 (columns...)
SELECT columns...
FROM DELETED
END
[/code]
Go to Top of Page

mody82
Starting Member

13 Posts

Posted - 2009-01-26 : 09:50:26
Thanks Visakh,,,
I tried it's working nicely
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-26 : 10:04:29
welcome
Go to Top of Page
   

- Advertisement -