I am not skilled in SQL and need some help. I have a SQL2005 server and I created a job to send an email with a CSV attachment. My job runs fine but I need the end result to be an Excel file in either .xls or .xlsx format.
Here is the code for the job:
USE My_DB GO EXEC msdb.dbo.sp_send_dbmail @profile_name = 'DBMail' ,@recipients = 'me@my_org.com' ,@copy_recipients = '' ,@execute_query_database = 'My_DB' ,@query = 'exec MY_RPT_MonthlyWIPSp' --@body =@bodyContent ,@subject = 'Monthly WIP Report' ,@attach_query_result_as_file = 1 ,@query_attachment_filename = 'result.csv' ,@query_result_separator=',',@query_result_width =32767 ,@query_result_no_padding=1;
What do I need to change and where to get the data to come out in the format I need? Do I have to modify my SP?