Future-proofing An Instead Of Insert Trigger
I've created an INSTEAD OF INSERT trigger on a child table that will automatically create a record in the parent table if necessary. I have the trigger working, but I am afraid it
Solution 1:
Inspired by this answer, I replaced these lines:
INSERT INTO Docs (AcctNum, SavedBy, SavedAt)
SELECT i.AcctNum, i.SavedBy, i.SavedAtFROM inserted as i;
with these lines:
SELECT*INTO #Docs FROM inserted;
ALTERTABLE #Docs DROPCOLUMN DocID;
INSERTINTO Docs SELECT*FROM #Docs;
DROPTABLE #Docs;
Large inserts could be a problem performance-wise, but if the application is limited to inserting rows one or a few at a time it should be OK.
Post a Comment for "Future-proofing An Instead Of Insert Trigger"