I do not think what I am trying to do is possible, but I could not find any documentation on this. I have an
INSTEAD OF UPDATE, INSERT, DELETE that always inserts data into a history table before performing the DML operation. So I created triggers that performed my insert into the history table and then I created 3
IF statements to figure out if the original operation was an
DELETE operation to continue the original operation.
Is there a way to perform my history insert and then tell SQL Server to continue with the original
DELETE without writing those myself? See my code below. We are using the standard edition of SQL Server, so no CDC to help with logging changes. Thank you.
SET NOCOUNT ON; -- ======================================================== -- STEP 1: ARCHIVE. Get the records that are being inserted -- or deleted and put them in the history table -- ======================================================== -- INSERT INTO HISTORY TABLE HERE -- ======================================================== -- STEP: CONTINUE. After archiving, perform the requested -- manipulation -- ======================================================== IF(EXISTS(SELECT * FROM inserted) AND NOT EXISTS(SELECT * FROM deleted)) BEGIN -- Perform insert into production table END IF(EXISTS(SELECT * FROM inserted) AND EXISTS(SELECT * FROM deleted)) BEGIN -- Perform update on production table END IF(NOT EXISTS(SELECT * FROM inserted) AND EXISTS(SELECT * FROM deleted)) -- Perform delete on production table END