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 |
DCW87
Starting Member
6 Posts |
Posted - 2012-06-21 : 10:45:35
|
hey guys,Can anyone advise me as to how to create a loop which will send an email to a list of contacts? for example, i have a contacts table (FK to another tables contacts_ID) and a table which contains a workload. I also have a script which works pefectly for a single user whereby i can send an email via MS alongisde an XLS extract of the workload. How do i create a job to do this for each unique contact ID in the workload table??Here's the email syntax:EXEC msdb.dbo.sp_send_dbmail@recipients=dave@me.com,@body= 'Here's your workload',@subject = '@User workload',@profile_name = 'SQL Mail',@execute_query_database = 'DB',@query ='select query (will be based on a contact ID variable),@attach_query_result_as_file = 1;Thanks in advance! |
|
|
|
|