I Try to export the Query result per E-Mail as Attach
here the code:
DECLARE @Delimiter Char(1)
SET @Delimiter = CHAR(9)
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'MyProfile',
@recipients = 'myemailaad@mail.com',
@subject = 'Defects Total Value',
@body='MyText',
@query= 'MyQuery',
@attach_query_result_as_file=1,
@query_result_no_padding=1,
@Query_Result_Header = 1,
@query_attachment_filename = 'Results.xls',
@query_result_separator =@Delimiter
it work normally but I have two issues:
The second row is empty : how deletet it(in the query)?
In the Query i use : SET NOCOUNT ON, but in the xls file I can see the count (see screenshot), how deletet it(in the query)?
Thanks in advance