﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / T-SQL (SS2K5)  / Using HTML sp_db_sendmail... can you conditionally set the CELL bgcolor when creating @tableHTML? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 09:49:20 GMT</lastBuildDate><ttl>20</ttl><item><title>Using HTML sp_db_sendmail... can you conditionally set the CELL bgcolor when creating @tableHTML?</title><link>http://www.sqlservercentral.com/Forums/Topic927067-338-1.aspx</link><description>Everything is doing what it should.  I end up with a 2 column HTML table using the following code, but I'd like to set the background color, [b]conditionally[/b], and at the [b]cell level[/b].[code="sql"]SET @tableHTML =	N'Your data ........................email.' +	N'&amp;lt;b&amp;gt;Property:  &amp;lt;/b&amp;gt;' + @prop + 	N'&amp;lt;b&amp;gt;Submitted:  &amp;lt;/b&amp;gt;' + @insert_dt + 	N'&amp;lt;b&amp;gt;Submit Type:  &amp;lt;/b&amp;gt;' + @zsubtype +     N'&amp;lt;table border="1 "cellpadding="10"&amp;gt;' +    N'&amp;lt;tr&amp;gt;&amp;lt;th align="center"&amp;gt;Month&amp;lt;/th&amp;gt;&amp;lt;th align="center"&amp;gt;Issue&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;' +    CAST ( ( 			SELECT 				td = ph.occ_month,				'	', -- xml col separator				td = COALESCE(ds.descr,'--')			FROM				#phold ph			LEFT OUTER JOIN				datasub_CHK ds				ON ph.months_out = ds.val1-1              FOR XML PATH('tr'), TYPE     ) AS NVARCHAR(MAX) ) +    N'&amp;lt;/table&amp;gt;'[/code]I'm trying to get "&amp;lt;td bgcolor="red"&amp;gt;" into the @tableHTML statement ONLY WHEN the second column of the SQL statement is a certain value (&amp;lt;&amp;gt; "--")Has anyone done this?  I can't screw with the SQL portion of the code without fouling the whole show.Thank you!</description><pubDate>Mon, 24 May 2010 14:20:26 GMT</pubDate><dc:creator>Greg J</dc:creator></item></channel></rss>