Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Insert on the row even if the trigger fails

Author  Topic 

doran_doran
Posting Yak Master

179 Posts

Posted - 2009-12-22 : 10:57:37
How to make the insert on the row occur even if the trigger fails.

Trigger works however I am using sp_send_dbmail and keep getting denied on the service account I am using. I would like the triggers to continue to insert even if the other pieces fails in the triggers (like send email, or the other db is not available, or permission issue).

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-22 : 12:15:01
You should not be sending email via a trigger. Instead you should write to a table that an email needs to be sent and then have a SQL Agent job check that table each minute to see if any emails need to be sent.

I suppose you could force the save via COMMIT TRAN though.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

doran_doran
Posting Yak Master

179 Posts

Posted - 2009-12-22 : 12:37:56
triggers are transaction by itself so adding tran and commit will not help. any other thought.

Also, I am sending data to another database. I would like trigger to continue even if the remote server is not responding. a separate log is being maintained for that.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-22 : 13:02:09
Like I said, this needs to happen from a SQL Agent job instead.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -