Hello, I am using sp_send_dbmail to create a CSV export. However, for some reason, the header line is "Splitting" into multiple lines upon export. I am trying to figure out what is causing this to happen to no avail as I need my header to stay in the top row. Here is my sp_send_dbmail code: DECLARE @Tab Char(1) = Char(9) DECLARE @Subj varchar(Max) = 'Reporting Enclosed!' DECLARE @Msg varchar(Max) = 'Reporting period is: ' + CONVERT(varchar(8),@StartDateTime,1) + ' - ' + CONVERT(varchar(8),@EndDateTime,1) + '.' -- for send_dbmail @Body DECLARE @Qry varchar(Max) = 'Set NoCount On SELECT * From ##DATA' DECLARE @File varchar(Max) = 'Rpt_.csv' DECLARE @Rec varchar(Max) = (CASE @DEBUG WHEN 'Y' THEN 'my@email.com' ELSE 'my@email.com;' END) EXEC msdb..sp_send_dbmail @Profile_name = 'Reporting', @Recipients = @Rec, @Subject = @Subj, @Body = @Msg, @Body_Format = 'Text', @Execute_Query_Database = 'myDB', @Query = @Qry, @Attach_Query_Result_As_File = 1, @Query_Attachment_Filename = @File, @Query_Result_Separator = @Tab, @Query_Result_No_Padding = 1Here are the results in CSV format:Field1 Field2 Field3 Field4 Field5 Field6 Field7 Field8 20161204 20161205 20161206 20161207 20161208 20161209 20161210 20161211 20161212 20161213 20161214 20161215 20161216 20161217 20161218 20161219 20161220 20161221 20161222 20161223 20161224 20161225 20161226 20161227 20161228 20161229 20161230 20161231 ------ ------ ---- ----- --- ----- ------ ------ -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- --------
↧