I have view_120DayEmailList which I want to set up as a job that every day returns a recordset of accounts whose expiration days are 120 days away.
Included in the recordset are the 3 account team members' email addresses. - so the view returns a recordset looking something like:
Account Broker AcctManager TechAssist
------- ------ ----------- ----------
ABCCorp Sally@x.com John@x.com Fred@x.com
XYZInc Bill@x.com Linda@x.com Carol@x.com
.
.
.
n....
Each day, if the recordset is not NULL, I need to be able to send a simple email alert to each of the Broker AcctManager and TechAssist email addresses for each retuned records
I am trying to somehow use:
but i am having trouble understanding how to manipulate the sets in TSQL to allow this to happen since there is no looping - Am I taking the right approach?
Included in the recordset are the 3 account team members' email addresses. - so the view returns a recordset looking something like:
Account Broker AcctManager TechAssist
------- ------ ----------- ----------
ABCCorp Sally@x.com John@x.com Fred@x.com
XYZInc Bill@x.com Linda@x.com Carol@x.com
.
.
.
n....
Each day, if the recordset is not NULL, I need to be able to send a simple email alert to each of the Broker AcctManager and TechAssist email addresses for each retuned records
I am trying to somehow use:
Code:
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'SQLServerDatabaseMailProfile',
@recipients = [COLOR=red] ALL OF THE RETURNED ADDRESSES[/color]
@body = 'ABC company is scheduled to be renewed in 120 days - GET TO WORK!',
@subject = 'ABC Company ALERT!' ;
but i am having trouble understanding how to manipulate the sets in TSQL to allow this to happen since there is no looping - Am I taking the right approach?