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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Send mail

Author  Topic 

mirravi
Starting Member

4 Posts

Posted - 2012-05-15 : 13:00:45
Hi,
i got a job to run a script at a fixed time and the result should send to the recipient .Please help in doing so.
Thanks in advance.

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-15 : 13:54:53
SQL server has pre-defined procedure by using this you ca send the mail to request.But for doing this you have to specify the all equired parameters
sp_send_dbmail...

GO through below link which will help you


http://msdn.microsoft.com/en-us/library/ms190307.aspx

Vijay is here to learn something from you guys.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-15 : 21:59:46
or another way is to use ssis with execute process task and send mail task. For running it at fixed time, Schedule a job in SQL Server agent to call and execute the package.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

zion_rulz
Starting Member

3 Posts

Posted - 2012-05-16 : 14:34:51
The link was really helpful. Thanks indeed. This link explains how to send the result of a query in txt and html format. Any advise on how to send the result in excel format.


quote:
Originally posted by vijays3

SQL server has pre-defined procedure by using this you ca send the mail to request.But for doing this you have to specify the all equired parameters
sp_send_dbmail...

GO through below link which will help you


http://msdn.microsoft.com/en-us/library/ms190307.aspx

Vijay is here to learn something from you guys.



Best Regards,
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-16 : 20:23:23
quote:
Originally posted by zion_rulz

The link was really helpful. Thanks indeed. This link explains how to send the result of a query in txt and html format. Any advise on how to send the result in excel format.


quote:
Originally posted by vijays3

SQL server has pre-defined procedure by using this you ca send the mail to request.But for doing this you have to specify the all equired parameters
sp_send_dbmail...

GO through below link which will help you


http://msdn.microsoft.com/en-us/library/ms190307.aspx

Vijay is here to learn something from you guys.



Best Regards,


first export results to excel using openrowset and then use sp_send_dbmail to attach it and send email.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -