2009-12-05 128 views
0

使用SQL Server 2000,我需要将从一个表中删除的记录插入到第二个表中。SQL Server 2000触发器

使用SQL Server 2000触发器实现此目的的最佳方法是什么?

,非常感谢和问候

SATHIA

回答

0

考虑这个删除触发器:

CREATE TRIGGER trig_delCustomer 

ON Customer --the table being deleted from 

FOR DELETE 

AS 

DECLARE @isOnContract BIT 

--insert all the effected rows (the ones being deleted) into this other table. 
INSERT INTO  
    MyOtherTable (ID, CustomerName, Email, Phone) 
SELECT 
    ID, [Name], Email, Phone 
    FROM Deleted