Convert a SQL query result table to an HTML table for email
问题 I am running a SQL query that returns a table of results. I want to send the table in an email using dbo.sp_send_dbMail. Is there a straightforward way within SQL to turn a table into an HTML table? Currently, I'm manually constructing it using COALESCE and putting the results into a varchar that I use as the emailBody. Is there a better way to do this? 回答1: Here is one way to do it from an article titled "Format query output into an HTML table - the easy way". You would need to substitute