有没有办法从下面的语句中格式化输出CSV,以便于Excel读取?到目前为止,它会打开所有乱成一列的列。我已经尝试过不同的deperators了。
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'auto-reporting'
, @recipients = @recipientsList
, @subject = 'MC Auto Reports'
, @query = 'select * from test.dbo.temp'
, @attach_query_result_as_file = 1
, @query_result_separator =','
, @query_result_no_padding = 1
, @query_attachment_filename = @FileName;发布于 2015-04-08 15:34:04
尝试在记事本中编辑生成的.csv文件。在第一行键入sep=,不带引号并保存它。然后尝试在Excel中打开它,如果它正确显示,那么您需要检查windows中的区域设置。
发布于 2015-04-09 08:59:52
试着改变
, @query_result_separator =','至
, @query_result_separator = @separator只需在发送电子邮件之前添加此代码
DECLARE @separator CHAR(1)
SET @separator = CHAR(9)这使得Excel更喜欢分隔符TAB。
https://stackoverflow.com/questions/29120399
复制相似问题