Link to home
Start Free TrialLog in
Avatar of jposp
jposp

asked on

Sending query result as CSV file using DatabaseMail - problem with header

I want to attach as CSV query output, so i wrote something like that:


EXEC msdb.dbo.sp_send_dbmail
@profile_name= 'ReportsSQL',
@recipients= 'mail@gmail.com',
@subject='Report',
@query ='SET NOCOUNT ON;SELECT login, name, city FROM users;SET NOCOUNT ON;',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'output.csv',
@query_result_no_padding = 1,
@append_query_error = 0,
@exclude_query_output = 1,
@query_result_header = 1,
@query_result_separator=';'

Output CSV file seems to be allright with one exception - secodn line:

login;name;city
-----;----;----
alex;Alexander;New York
misza;Misza;Moscow

Open in new window


How to get ridd of the second line with dashes ???
ASKER CERTIFIED SOLUTION
Avatar of Harish Varghese
Harish Varghese
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jposp
jposp

ASKER

@harish_varghese - solution works for me :)