Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

email query results as csv - How to avoid the dashes after the header row.

$
0
0
Hi guys,Please help to avoid the hyphens in the second row after the header row. I use the query below. Also how can I change this format to save as excel.DECLARE @DL CHAR(1) = CHAR(9);EXEC msdb.dbo.sp_send_dbmail @profile_name = 'Profile1', @recipients = 'xxxxxx@xxx.com', @execute_query_database= 'Mydb', @query = @sqlquery, @query_attachment_filename=results.csv, @query_result_no_padding=1, @query_result_separator=@DL, @subject = @subject1, @body=@body, @attach_query_result_as_file = 1 ;csv output:Column1 Column2 Column3 ------------- ----------- ------------ 1 abc 123 2 ads 234I wanted the output like this:Column1 Column2 Column3 1 abc 123 2 ads 234

Viewing all articles
Browse latest Browse all 6525

Trending Articles