How can I send Excel from sql server?

2

Good Night. I'm exporting an excel file to my email from SQL SERVER 2012

Why, if it generates me and my email arrives to me the excel the bad thing is that it comes out in a single cell as the image that I attached Would there be a way to format the excel?

The code that generates and sends to the mail is this:

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'IncidenciasQa',
@recipients = '[email protected]',
@subject = 'Test',
@query = N'exec DBRevisoria.dbo.[Sp_RevCatalogo] 13,2',  
@attach_query_result_as_file = 1,
@query_result_width = 150,
@query_result_header= 1,
@query_attachment_filename = 'test.xls',
@importance = 'High',
@query_result_no_padding = 1,
@query_result_separator = '     '

    
asked by PieroDev 18.01.2018 в 01:12
source

1 answer

0

Unfortunately a "pure" Excel will not be able to generate, but if a file of fields separated by commas ( CSV ) that you could eventually import into Excel, to do this you should add the following parameters:

@query_result_separator = ',', -- El separador de campos será la ,  
@query_result_no_padding = 1   -- Para quitar el espacio "extra" de cada columna

Anything reviews the documentation of sp_send_dbmail

    
answered by 18.01.2018 в 03:45