Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining whether UPDATE or INSERT was called
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01467465
Message ID:
01467466
Views:
37
Like I said earlier, the only way I know to check is something like this:


IF EXISTS (SELECT * FROM DELETED) -- a DELETE was done

IF EXISTS (SELECT * FROM INSERTED) -- an INSERT was done.


If your INSTEAD OF trigger is checking either for an INSERT or a DELETE, only one of the two conditions will be true, but not both.. (Obviously, in an UPDATE, both will be true, but I don't think you're asking about that one.


I'd be curious if there's another way - though not sure it would be any less lines of code than above.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform