sp_send_dbmail附件编码

时间:2020-03-05 18:47:20  来源:igfitidea点击:

我在SQL2005中使用sp_send_dbmail发送带有结果的电子邮件附件。发送附件后,它是UCS-2编码的,我希望它是ANSI或者UTF-8.

这是SQL

EXEC msdb.dbo.sp_send_dbmail
    @recipients = '[email protected]'
    , @query = 'DECLARE @string_to_trim varchar(60);SET @string_to_trim = ''1234''; select rtrim(@string_to_trim), ''tom'''
    , @query_result_header=0
    , @subject = 'see attach'
    , @body= 'temp body'
    , @profile_name= N'wksql01tAdmin'
    , @body_format = 'HTML'
    ,@query_result_separator = ','
    ,@query_attachment_filename = 'results.csv'
    ,@query_no_truncate = '0'
    ,@attach_query_result_as_file = 1

我已经在Internet上看到一些评论,该评论已在sql2005 SP2中修复,但没有发现这种情况。

解决方案

回答

我认为解决我们所看到的内容的唯一方法是使用BCP将数据转储到平面文件中,然后添加该文件。抱歉,我帮不上什么忙。 :(