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 2000 Forums
 Transact-SQL (2000)
 Trigger

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-28 : 14:13:05
Krish writes "I need to capture delete operations from a table.
Any records deleted from a table need to be inserted
into a history-of-deletes sort of table.

I was wondering how to achieve this with triggers

Thanks"

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-28 : 14:15:15
When a delete trigger fires, a deleted table is created that contains the deleted information. So use the deleted table to insert the rows into your auditting table.

INSERT INTO Table1
SELECT *
FROM deleted

Tara
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-04-28 : 14:27:15
see
http://www.nigelrivett.net/Triggers_1_A_beginners_guide.html
http://www.nigelrivett.net/Triggers_2_Creating_Audit_Trails.html
http://www.nigelrivett.net/AuditTrailTrigger.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -