views:

28

answers:

2

Using SQL Server 2000, I need to insert the deleted records from one table into a second table.

What's the best way to achieve this using a SQL Server 2000 trigger?

with thanks and regards

Sathia

+1  A: 

Have a look at these articles

Using Triggers In MS SQL Server

and

Delete trigger

astander
A: 

Consider this delete trigger:

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
p.campbell