Wednesday, March 21, 2012

Email results from trigger tables

I'm trying to e-mail the results of a trigger that fires on an employee
table. I'm trying to included the results of either the DELETED or INSERTED
tables, but nothing is returned. Can xp_sendmail include DELETED or INSERTE
D
table queries in the @.query = parameter?
I'm trying to send an e-mail to someone whenever a new employee is added or
deleted.
Thanks.Regardless that doesn′t work because the new session with XP_sendmail won′
t
know about your deleted tables, the action you want to perform is not
preferable, because mail sending will be done synchronisly. So if your
mailserver is stuck in a problem and need 5 minutes for sending a mail (for
some reason) your transaction will hold on for that time, if the process
throws an error, your transaction might rollback. You don′t want that, erh
?
I would suggest (as this is not time critical) to write the data in a table
which is regulary checked for content to be sent.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Shawn Barrow" wrote:

> I'm trying to e-mail the results of a trigger that fires on an employee
> table. I'm trying to included the results of either the DELETED or INSERT
ED
> tables, but nothing is returned. Can xp_sendmail include DELETED or INSER
TED
> table queries in the @.query = parameter?
> I'm trying to send an e-mail to someone whenever a new employee is added o
r
> deleted.
> Thanks.

No comments:

Post a Comment