question

TonyVelarde-3612 avatar image
0 Votes"
TonyVelarde-3612 asked ·

Change font colour in table cell based on SQL Query in SQL Email

Hi All,
I am generating a Report through SQL that emails a set of data results in a HTML table to Fee Earners in our firm. I would like to know, how I can set the font to red when the "Total" is greater than $10,000. The SQL code I have for the Email body is as follows:

SET @tableHTML =
N'<h2 style=''font-family:arial;color:#048a55;''>Fees and Disbursements Report</h2>' +
N'<p style=''font-family:arial;color:#555555;''>This is an automated email. Please review your Fees and Disbursements Report.<br/><br/>Thank you.<br/>Account Team</p>' +
N'<table style=''text-align:center;font-family:arial;color:#555555;font-size:15px'' border="1">' +
N'<tr><th style="background-color: #05fcb6;">Client Code</th><th style="background-color: #05fcb6;">Client Name</th><th style="background-color: #05fcb6;">Matter Code</th>
<th style="background-color: #05fcb6;">Matter Description</th><th style="background-color: #05e7fc;">Total Fees</th>
<th style="background-color: #05e7fc;">Total Disbursements</th><th style="background-color: #05e7fc;">Total</th></tr>' +

CAST ( ( SELECT
td = CLIENT_CODE, '',
'left' AS 'td/@align',
td = CLIENT_NAME, '',
td = MATTER_CODE, '',
'left' AS 'td/@align',
td = LONG_MATT_NAME, '',
'right' AS 'td/@align',
td = '$' + FORMAT(TOTAL_FEES, 'N2'), '',
'right' AS 'td/@align',
td = '$' + FORMAT(TOTAL_DISB, 'N2'), '',
'right' AS 'td/@align',
td = '$' + FORMAT(TOTAL, 'N2'), ''
FROM #WIP_DISB_EMAIL
WHERE EMAIL = @Email
ORDER BY CLIENT_CODE, TOTAL_FEES DESC
FOR XML PATH('tr'), TYPE) AS NVARCHAR(MAX) ) +
N'</table>' +
N'</br></br>' +
+
Any help would be greatly appreciated.
Regards
Tony

not-supported
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered ·

QnA currently supports the products listed here (more to be added) Better to reach out to subject matter experts in dedicated forums over here.


https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver


(please don't forget to mark helpful replies as answer)


Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management


Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.




· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TonyVelarde-3612 avatar image
0 Votes"
TonyVelarde-3612 answered ·

Thanks Dave

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DSPatrick avatar image
0 Votes"
DSPatrick answered ·

You're welcome.

(please don't forget to mark helpful replies as answer)





· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.