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.
Author |
Topic |
wldodds
Starting Member
20 Posts |
Posted - 2014-07-02 : 07:46:11
|
I'm familiar with using db mail to send notifications of changes to records within a database table. I've done this many times using triggers. In addition, I have setup sql jobs to run daily to send an email with or without an attachment to a defined list of recipients.What I would like to do now is send an email to completely different recipients that contains completely different content on a schedule but I do not want to have to hard code the recipients in the sql job steps.I have a table that contains a list of employee's and their supervisors. In another table I have a record for each supervisor and associated email. There is a 3rd table which contains PTO requests by employee with a column 'DateCreated'. I would like to setup a sql job that will send the Employee's Supervisor an email 1 time per day for the previous day's PTO requests. I can get the Supervisor and PTO records and emails without any issue. What I'm wondering is if I setup the sql job with the variable @Recipient and my select query returns 5 records to send an email to (5 different supervisors with maybe 30 different direct reports), will the send mail function loop through and send 5 emails or does my record set for @Recipient have to return only 1 record and I would then need to create 5 separate steps in my sql job to send the 5 different emails.Any help on how best to accomplish this would be greatly appreciated. |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-07-02 : 08:02:35
|
This problem cries out for a SSIS solution. |
|
|
|
|
|