I am trying to make HTML report in SQL Server. I have to make row background color different when one of my cell contains sth.
It is possible to add class to tr tag in case of ... or just defined style attrib?
edit
DECLARE @tableHTML NVARCHAR(MAX) ;
DECLARE @dzisiaj as date
SET @dzisiaj = CAST(CONVERT(varchar(10), GetDate(),126) as varchar)
DECLARE @tytul as varchar(100)
SET @tytul = 'Raport z dnia ' + cast (@dzisiaj as varchar)
SET @tableHTML =
N'<style type="text/css">
h1 {font-size: 24px; font-family: Verdana;}
td,th {min-width:100px;max-width:200px;border-collapse:collapse;border-spacing:0;text-align:center;font-family:Verdana;padding:4px;border-style:solid;border-width:1px;border-color: black;overflow:hidden;word-break:normal; line-break: word-wrap}
th, .first {font-weight:bold;font-size:12px;background-color:#354458;color:#ffffff;}
td {font-size: 10px;background-color:#DCDDCD;color:#000000; }
</style></br></br>' +
N'<H1>Raport z dnia ' + cast (@dzisiaj as varchar) + '</H1>' +
N'<table border="1">' +
N'<tr><th>Lp</th><th>Filia</th><th>Nazwa</th>' +
CAST ((
SELECT
td = ROW_NUMBER() OVER (ORDER BY o_filia asc), '',
td = [o_filia], '',
td = [o_opis], '',
FROM [dbo].[oddzialy]
ORDER BY o_filia asc
FOR XML PATH('tr'), TYPE ) AS NVARCHAR(MAX) ) + '</table>' ;
EXEC msdb.dbo.sp_send_dbmail @recipients='tomipnh@gmail.com',
@subject = @tytul,
@body = @tableHTML,
@body_format = 'HTML' ;
I want to use different background-color in case o_filia equals "A" It is there simple trick or I have to use case statement of whole row generate?