How can I send a query automatically to email addresses
-
Tuesday, September 13, 2011 2:35 PM
Hey folks,
Could you please let me know or give an idea how I can send a query results automatically to email addresses?
I made a .NET application using:
- VS2008, c#
- Sql Server 2008 R2
- The application is hosted on a Windows 2008 Server
Basicly I need to execute a query by pressing a button in a WebForm and the results of that query sent to users to their email accounts.
Thanks you very much in advance,
Marco
All Replies
-
Wednesday, September 14, 2011 6:17 AMModerator
Hi Marco,
To send the query result to an email address, one simple way is using SQL Server database mail. You can run a T-SQL with sp_send_dbmail to do it. Please pay attention to the blog below with the sample code:
SQL Database Mail - Send T-SQL Results by EmailHope this helps.
Best Regards,
Stephanie Lv
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
Wednesday, September 14, 2011 5:07 PM
Thanks Stephanie for your answer.
I'd like to send it automatically, let's say at 3.00 am everyday. Do you know a blog where I can find it out?
Thanks,
Marco
-
Thursday, September 15, 2011 1:28 AMModerator
Hi Marco,
To send eamil automatically at a fixed period, you can schedule a SQL Server Agent job to run this stored procedure. Please have a look at: how to execute a stored procedure in a SQL Agent job?
Best Regards,
Stephanie Lv
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com. -
Thursday, September 15, 2011 2:33 PM
Thanks folks.
I managed to fix my problem. These great threads helped me a lot (in this order):
http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/62678/
http://www.sql-server-performance.com/2008/scheduling-a-ssis-package-in-sql-server-agent/4/
http://thebipalace.wordpress.com/2011/03/13/ssis-sql-server-and-file-system-deployment/
Regards,
Marco

