March 30, 2017 at 7:03 am
An after insert trigger is still all part of the same transaction, it just means that the trigger happens after the insertion, rather than before or instead of. If any part of a transaction fails (in this case permission denied), then the whole transaction rolls back.
You'll either need to stop the trigger sending an email when the user making the insert is the service account (use an if statement in the trigger to check the user), grant permission for the service account to send emails, or remove/disable the trigger.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
March 30, 2017 at 7:35 am
I would consider architecting this differently.
Instead of using a trigger, set up a job which runs periodically (every x minutes), checks for new inserts (I assume that there is a suitable data stamp somewhere) and sends an e-mail if any are found.
March 30, 2017 at 11:21 am
ALTER PROCEDURE myproc @param1 WITH EXECUTE AS 'Login with email permissions'
AS
...
GO
Viewing 3 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply