2009-12-05 75 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