如何从SQL Server导出数据库数据并按计划将其发送到电子邮件? [英] How do I export database data from sql server and send it to an email on a scheduled basis?
本文介绍了如何从SQL Server导出数据库数据并按计划将其发送到电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够从数据库表或整个数据库中检索内容,如果可能,将其打包到excel文件中,然后将其发送到某个电子邮件地址。
我目前没有使用任何服务器,因为我只是从我自己的电脑上试用它。关于如何做的任何想法?
我使用的是Microsoft SQL Server 2012.
谢谢提前获取帮助。
I want to be able to retrieve contents from a database table or the whole database if possible, package it into a excel file and then send it to a certain email address.
I am not using any server at the moment, as I am only trying it out from my own PC. Any ideas on how it can be done?
I am using Microsoft SQL Server 2012.
Thank you in advance for the help.
推荐答案
转到您的Sqlserver管理工作室并右键单击数据库。
转到任务并导出。(下面)并使用向导将其导出到目的地excell。
创建一个包。
创建数据库邮件配置文件请参阅:
http://msdn.microsoft.com/en-us/library/ms187605%28v=sql.110%29.aspx [ ^ ]
通过两个步骤创建代理作业。
步骤1创建excel使用您创建的包的文件。 (为此步骤选择类型SSIS包。)
步骤2使用sp_send_dbmail存储过程使用databasemail配置文件和excell附件发送电子邮件。
完成此计划后,启用它。
Go to your Sqlserver management studio and right click on the database.
Go to tasks and Export.(below) And export it with destination excell using the wizard.
create a package with this.
Create a databasemail profile see:
http://msdn.microsoft.com/en-us/library/ms187605%28v=sql.110%29.aspx[^]
Create an agent job with two steps.
step 1 Create the excel file using the package that you created. (Choose type SSIS Package for this step.)
step 2 Use the sp_send_dbmail stored procedure to send the email using the databasemail profile and the excell attchament.
After this schedule the job and enable it.
这篇关于如何从SQL Server导出数据库数据并按计划将其发送到电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文