title: Can I transform XML to HTML in SQL Server?
body: <p>I have a query that returns data as XML using the "for XML Clause" and then sends the result as the body of an email like so.</p>
  
  <pre><code>Declare @messBody as nvarchar(max)
  Set @messBody = (Select * from tablehere where state = 1 for xml Auto)
  Begin
    Exec msdb.dbo.ap_send_dbmail
        @profile_name = 'ProfileNameHere'
        @recipients = 'simon@example.com'
        @body = '@messBody
        @subject = 'SubjectHere'
  End
  </code></pre>
  
  <p>It works and I get the email with the info I need but the body of the email is ugly XML. I would like to be able to transform it into pretty HTML.
  Can this be done in SQL Server?  </p>