Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
INSTEAD OF Triggers
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01467449
Message ID:
01467459
Views:
44
Would this mean that my original INSERT command (not in the TRIGGER, but which sets off the trigger) is never used? And, that if I want that INSERT to succeed, I have to write an INSERT within the trigger? So, what if your INSTEAD OF trigger is used for both INSERT and DELETE, would you therefore have to detect if the user is doing a DELETE, or an INSERT, first? And then write code to do either one, based on what was in the call?

On the question of whether your INSTEAD OF Trigger is used for both an INSERT and a DELETE....I'm not 100% positive, mainly because I've never written a single INSERTED OF trigger for both. I supposed you could query the count of INSERTED and DELETED to determine which statement is being used (on an INSERT, the Deleted table would be empty, and vice-versa for an UPDATE). There may be other ways as well.

But beyond that...in an INSTEAD OF, if you still wanted to do the INSERT, as far as I know, yes, you'd have to do it yourself. (And I'm sure you realize this, but just to mention it...any time I'm curious about behavior, I'll never hesitate to create a few dummy tables and a trigger or proc or whatever, to test something out).
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform