附加csv文件以在sql server中发送电子邮件 [英] attach csv file to send email in sql server

查看:83
本文介绍了附加csv文件以在sql server中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表格中有一些记录。我希望表记录生成csv文件,该文件使用sql server将其发送到邮件。

I have some of records in a table. I want that table records to generate csv file and that file send it to mail using sql server.

推荐答案

检查这个



sp_send_dbmail(Transact-SQL)

[ ^ ]



示例代码



check this

sp_send_dbmail (Transact-SQL)
[^]

sample code

EXEC sp_send_dbmail @profile_name='default',
@recipients='dev@null.com',
@subject=@SUB,
@body=@BODY,

@query= 'SELECT [MID],[HID],[MeC],[LC],[RowCDate]
FROM [JBC].[dbo].[Table1] WHERE RowCDate >= GETDATE()
',
@attach_query_result_as_file=1
@query_attachment_filename = 'Results.csv',
@query_result_separator = ','






如何先将其转换为csv并保存。看看这里



然后就可以了读取保存的文件,附加和发送邮件。看这里



问候,

Praneet
Hi,

How about first converting it to csv and saving it. Look here.

Then you can read the saved file, attach and send mail. Look here

Regards,
Praneet


这篇关于附加csv文件以在sql server中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆