Answered by:
How to automate a an sql and to send the result as an email to the user

Question
-
Please can you advise me how to automate an sql and to send the result as an email to the user in weekly basis .
Please can you advise me
polachan
Thursday, November 17, 2016 1:52 PM
Answers
-
email sending is not possible in express edition.
Please Mark it as Answered if it answered your question OR mark it as Helpful if it help you to solve your problem.
- Proposed as answer by Albert_ Zhang Monday, November 21, 2016 6:52 AM
- Marked as answer by Kalman Toth Monday, December 19, 2016 3:21 PM
Sunday, November 20, 2016 3:52 PM -
Hi Polachan
This may help you , you can send email using window-task-scheduler option.
Please Mark it as Answered if it answered your question OR mark it as Helpful if it help you to solve your problem.
- Proposed as answer by Albert_ Zhang Monday, November 21, 2016 6:52 AM
- Marked as answer by Kalman Toth Monday, December 19, 2016 3:21 PM
Sunday, November 20, 2016 3:56 PM -
Hi polachan,
As Vishe said above, Database Mail is not available in SQL Server Express. For this, please refer to following article.
https://msdn.microsoft.com/en-us/library/ms175887.aspx?f=255&mspperror=-2147217396
If you want to send scheduled email, if possible, you could also refer to following links to create some applications to achieve it.
https://forums.asp.net/t/1959860.aspx?Send+Email+on+every+wednesday+at+10+00+AM
https://code.msdn.microsoft.com/CSEmailScheduler-21564366
Best Regards,
Albert Zhang
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Marked as answer by Kalman Toth Monday, December 19, 2016 3:22 PM
Monday, November 21, 2016 7:00 AM
All replies
-
Use this link to Configure Database Mail: -
https://msdn.microsoft.com/en-us/library/hh245116.aspx?f=255&MSPPError=-2147217396
Set up a SQL Server Agent Job to send the query results as an attachment to the recipients: -
https://msdn.microsoft.com/en-us/library/ms190307.aspx
Note this won't work with SQL Server Express as SQL Server Agent is required to create the Job
Please click "Mark As Answer" if my post helped. Tony C.
- Edited by Anthony C-UK Thursday, November 17, 2016 2:03 PM
Thursday, November 17, 2016 2:02 PM -
Hi Polachan,
You have scedule job for weekly following query in sql agent
USE msdb
EXEC sp_send_dbmail
@profile_name = ‘MailProfile1’, --profile mail
@recipients = ‘someone@microsoft.com’, -- email address
@subject = ‘T-SQL Query Result’,
@body = ‘The result from SELECT is appended below.’,
@execute_query_database = ‘msdb’,
@query = ‘SELECT subsystem_id,subsystem FROM syssubsystems’ --queryRefer following ink
https://blogs.msdn.microsoft.com/sqlagent/2010/11/03/sql-database-mail-send-t-sql-results-by-email/
Please click Mark As Answer if my post helped.
Thursday, November 17, 2016 2:06 PM -
Hi,
send automatic notification email
http://www.aspsnippets.com/Articles/Automated-Email-Notifications-using-SQL-Server-Job-Schedular.aspx
Please click Mark As Answer if my post helped.
Thursday, November 17, 2016 2:20 PM -
Thanks for the reply
I am using sqlserver express edition, is it possible sqlagent to configure express edition. If so please can you let me know the steps
Regards
Pol
polachan
Friday, November 18, 2016 9:39 AM -
Thanks for the reply
I am using sqlserver express edition, is it possible sqlagent to configure express edition. If so please can you let me know the steps. I cannot see the option 'Configure Database Mail.' in database management. Please can you help
Regards
Pol
polachan
Friday, November 18, 2016 9:40 AM -
email sending is not possible in express edition.
Please Mark it as Answered if it answered your question OR mark it as Helpful if it help you to solve your problem.
- Proposed as answer by Albert_ Zhang Monday, November 21, 2016 6:52 AM
- Marked as answer by Kalman Toth Monday, December 19, 2016 3:21 PM
Sunday, November 20, 2016 3:52 PM -
Hi Polachan
This may help you , you can send email using window-task-scheduler option.
Please Mark it as Answered if it answered your question OR mark it as Helpful if it help you to solve your problem.
- Proposed as answer by Albert_ Zhang Monday, November 21, 2016 6:52 AM
- Marked as answer by Kalman Toth Monday, December 19, 2016 3:21 PM
Sunday, November 20, 2016 3:56 PM -
Hi polachan,
As Vishe said above, Database Mail is not available in SQL Server Express. For this, please refer to following article.
https://msdn.microsoft.com/en-us/library/ms175887.aspx?f=255&mspperror=-2147217396
If you want to send scheduled email, if possible, you could also refer to following links to create some applications to achieve it.
https://forums.asp.net/t/1959860.aspx?Send+Email+on+every+wednesday+at+10+00+AM
https://code.msdn.microsoft.com/CSEmailScheduler-21564366
Best Regards,
Albert Zhang
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Marked as answer by Kalman Toth Monday, December 19, 2016 3:22 PM
Monday, November 21, 2016 7:00 AM