sending multiple emails as a result of an update staement
Posted on 2008-10-08
I'm trying to set up some code in a stored procedure that will send out an email for each row affected by an update statement.
For example, the update statement is:
Update table 1
set status = 'done'
where status = 'not done'
lets say 50 rows are affcted by that statement when its triggered
each row has a column called id. I want to get the id's of these 50 rows that were updated and send out 50 emails, one for each row affected with the id on each email.
I'm using msdb.dbo.sp_send_dbmail to handle the sending of the emails