I've been tasked with sending a small monthly report to for one of my customers. The report has previously been run manually on the instance, the output copied to a spreadsheet and send to the customer as an attachment.
I'm looking for a more permanent solution, so I intend on using
sp_send_dbmail stored procedure to run the query and send it as an attachment.
Everything works but the formatting of the message. Initially I tried to attach the output as a CSV file with a
@query_result_seperator = ',' but the results were everywhere!
When I run the report normally, the output looks fine in SQL. But sending it as a CSV or just in the message body doesn't.
I think it might work better if I export the output as HTML and send that as an attachment/or as XML but I don't know how to do this.
Does anyone have any suggestions?
Thanks in advance!