I'm confused on which Delete trigger to use (For, After, ...)
I need to save the entire deleted record(s) in another table.
I've found many examples bot not quite sure which is best to use, or what options might be faster
This one I found will work, just wondering if there are other options for the delete trigger are better for what I'm trying to accomplish.
Auguy
Sylvania/Toledo Ohio
I need to save the entire deleted record(s) in another table.
I've found many examples bot not quite sure which is best to use, or what options might be faster
This one I found will work, just wondering if there are other options for the delete trigger are better for what I'm trying to accomplish.
Code:
CREATE TRIGGER dbo.SampleTable_DeleteTrigger
ON dbo.SampleTable
FOR DELETE
AS
BEGIN
INSERT INTO dbo.SampleTable_Audit
(SampleTableID, SampleTableInt, SampleTableChar, SampleTableVarChar, Operation, TriggerTable)
SELECT SampleTableID, SampleTableInt, SampleTableChar, SampleTableVarChar, 'D', 'D'
FROM deleted;
END;
GO
Auguy
Sylvania/Toledo Ohio