I have a query to retrieve the email ids from my demo table. I have also configured database email on my sql server. But I am new to sql server agent jobs. I want to send reminders to people who havent filled there daily task report at a specific time daily. Could anyone help me with detailed steps to create a job?
Asked
Active
Viewed 6,427 times
0
-
http://stackoverflow.com/help/how-to-ask – Mihai Sep 22 '14 at 14:06
-
Pls refer following link you will get necessary details http://technet.microsoft.com/en-us/library/ms190606(v=sql.105).aspx – Bhasyakarulu Kottakota Sep 22 '14 at 14:27
-
I did refer the link but of no help. I have a stored procedure that will give me the list of recipients. I have a database mail profile. I want a sql job to use this profile and send mail to the recipients list that we get from the stored procedure daily at a specific time – Manish Sep 22 '14 at 15:15
2 Answers
0
In that case, I beleive you need to use a query in the last step of your job and send the email using the stored_proc sp_send_dbmail (http://msdn.microsoft.com/fr-ca/library/ms190307.aspx) Hope this help

iTekExpert
- 31
- 9
-
I went through the link you provided. I think my question is not very clear. I have a db table where everyone fills their tasks daily. At 8pm i want my job to run a query first to check who all have not filled their tasks. The result of the query would give multiple email addresses. After that the database should send reminder emails to fill the task to those email addresses. And this should happen daily. Here is the query ------------------- select l.emailid as 'Email ID' from demologin l left join demotasks t on l.empid =t.empid and t.taskdate='9/23/2014' where t.todaystask is null – Manish Sep 23 '14 at 07:00
-
Its more like I have a query or stored proc to get the recipient list from db. Then another stored proc(sp_send_dbmail) to send emails to that recipient list(which is a result set) and I want this to be executed daily at a specific time. – Manish Sep 23 '14 at 07:03
0
So basically you'll fetch all email addresses, store it in a temp table, and then trigger a mail in a loop by calling msdb.dbo.sp_send_dbmail for each of the email addresses from your stored proc. The job created will trigger at a scheduled time and call your stored proc that will do all this tasks. But before you start sending emails from SQL Server, you need to enable and configure Database Mail: https://database.guide/how-to-send-emails-from-sql-server-t-sql/

Chintan
- 1
- 1