-1

我正在使用此查询发送每日报告。我应该对代码进行哪些更改以获取 html 格式的输出?

EXEC msdb.dbo.sp_send_dbmail
     @profile_name = 'DBMAIL',
     @recipients = 'aa@xyz.com',
     @query = 'Select Country, CompanyName, round(sum(TotalSale), 0) as Sale, count(*) as DownloadedCount from PW.dbo.SalesReport group by Country, CompanyName order by Country',
     @subject = 'Daily Sales Report' ;

EXEC msdb.dbo.sp_send_dbmail
     @profile_name = 'DBMAIL',
     @recipients = 'aa@xyz.com',
     @query = 'Select Country,ltrim(rtrim([Store Name])) as Store, round(sum(TotalSale), 0) as Sale, space(3), max(Convert(varchar(10), LastTime, 108)) as [Last update Time] from PW.dbo.SalesReport where len(Country) > 1 group by Country, [Store Name] order by Country, [Store Name]',
     @subject = 'Daily Sales Detail'
4

1 回答 1

0

If you would just quickly consult the official MSDN documentation on sp_send_dbmail - you would easily see this:

[ @body_format= ] 'body_format'

Is the format of the message body. The parameter is of type varchar(20), with a default of NULL. When specified, the headers of the outgoing message are set to indicate that the message body has the specified format. The parameter may contain one of the following values:

TEXT
HTML

Defaults to TEXT.

So just add

@body_format = 'HTML'

to your calls and you should get the HTML format you're looking for.

于 2015-05-02T18:23:55.277 回答