建表数据
- SQL code
create table abc (aa varchar(20), bb varchar(20), cc varchar(20))insert into abc values('1','1','1')insert into abc values('2','2','2')insert into abc values('3','3','3')select * from abc
执行SQL
- SQL code
EXEC msdb.dbo.sp_send_dbmail @profile_name = 'NO-REPLY', @recipients = [email protected]', @body = 'The stored procedure finished successfully.', @subject = 'Automated Success Message', @execute_query_database = 'DB', @query = 'select * from abc', @attach_query_result_as_file = 1, @query_attachment_filename = 'test.csv'
打开CSV文件看到如下结果
aa bb cc
-------------------- -------------------- --------------------
1 1 1
2 2 2
3 3 3
(3 rows affected)
问题: 希望邮件收到的CSV文件格式(使用文本打开)如下: 求解决, 谢谢
aa,bb,cc
1,1,1
2,2,2
3,3,3
------解决方案--------------------
这个貌似只能在创建CSV文件的时候就安照客户希望的文本形式创建吧
------解决方案--------------------