DECLARE @tableHTML NVARCHAR(MAX);
SET @tableHTML = N'<H3 style="font-family:verdana;color:darkblue;">Header1</H3>' + N'<H5 style="font-family:verdana;color:darkblue;">SubHeader:</H5>' + N'<H6 style="font-family:verdana;color:darkblue;">SubHeader2<br> SubHeader3</H6>' + N'<table border="1";>' + N'<tr>' + N'<th style="text-align:right;">MiscColumn1</th>' + N'<th style="text-align:right;">MiscColumn2</th>' + N'<th style="text-align:right;">MiscColumn3</th>' + N'<th style="text-align:right;">MiscColumn4</th>' + N'<th style="text-align:right;">MiscColumn5</th>' + CAST ( (SELECT td = SE.MiscColumn1, '', td = SE.MiscColumn2, '', td = SE.MiscColumn3, '', td = SE.MiscColumn4, '', td = SE.MiscColumn5, '' FROM database.dbo.table SE FOR XML PATH('tr'), TYPE ) AS NVARCHAR(MAX) ) + N'</table>'; EXEC msdb.dbo.sp_send_dbmail @profile_name = 'Mail_Profile', @recipients='my@email.com', @copy_recipients = '', @subject = 'Sending an email', @body = @tableHTML, @body_format = 'HTML';https://learn.microsoft.com/en-us/answers/questions/1409670/sql-server-query-to-html-table-email-justify-text
No hay comentarios:
Publicar un comentario