Database mail with excel attached with a format way

SVA 116 Reputation points
2023-05-11T05:26:04.3033333+00:00

Hi

How to send a query output in excel with a formatted way in runtime by using EXEC msdb.dbo.Sp_send_dbmail.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,361 questions
{count} votes

2 answers

Sort by: Most helpful
  1. PercyTang-MSFT 12,426 Reputation points Microsoft Vendor
    2023-05-11T05:59:31.48+00:00

    Hi @SVA

    Do you want to send the result in excel format?

    You seem to give little information.

    Can this thread help you?

    https://stackoverflow.com/questions/44315299/want-to-execute-sp-send-dbmail-and-send-results-in-excel-format

    Best regards,

    Percy Tang


  2. Olaf Helper 43,246 Reputation points
    2023-05-11T06:41:11.7666667+00:00

    How to send a query output in excel with a formatted way

    You simply can not.

    What do you expect, SQL Server is a database server, not an application server.

    Use an application server or at least a PowerShell script to generate & format an MS Excel file; SQL Server can't do this.