A way of sending e-mail on SQL Server after trigger
What is the best way of sending e-mail on SQL Server with an after
trigger? I have found some articles on that but they seem to be a little old.
My goal here is to send an e-mail to admin that some values are insert开发者_如何学Goed into a table.
I am on SQL Server 2008 R2 now.
I would recommend inserting a record into an emailPending table in the trigger, then have a job that inspects this table and sends any emails.
Putting a send_dbmail inside a trigger is not advisable because send_dbmail can stall for any number of reasons.
just execute EXEC msdb.dbo.sp_send_dbmail (Transact-SQL) from inside the trigger, or am I missing something here?
aditional reading: Database Mail and SQL Mail Stored Procedures (Transact-SQL) and Database Mail
精彩评论