I am working on tsql to create an html report. The existing table is a list of error_codes organized as follows:
to clarify what is this table doing, it is just listing error codes and description for that error... Some errors are headers and some are not! The header entries marked with 1
| error_code | error_disc | error_seq | isHeader |
-----------------------------------------------------------------
| XYT3 | Description for this error | 100 | 1 |
-----------------------------------------------------------------
| ZTY5 | Another description | 101 | 1 |
-----------------------------------------------------------------
| UJ0B1 | A child error entry | 102 | 0 |
-----------------------------------------------------------------
| XXCV | Another header | 103 | 1 |
-----------------------------------------------------------------
| GTER4 | Second child entry | 104 | 0 |
-----------------------------------------------------------------
I need to display that table in HTML format and make every header with its child error entries in a separate <tr>
I used the following code:
declare @listErrorMsgs varchar(max) = (
SELECT
CASE
WHEN isHeader = 1 THEN 'vertical-align: text-top; border-top: 1px solid #2c3e50; font-weight: bold;'
ELSE 'vertical-align: text-top;' END as [td/@style] , error_disc as td, '',
CASE
WHEN isHeader = 1 THEN 'vertical-align: text-top; border-top: 1px solid #2c3e50; font-weight: bold;'
ELSE 'vertical-align: text-top;' END as [td/@style] , error_code as td, ''
FROM #Table
ORDER BY error_seq
FOR XML PATH('tr')
)
The results were very good, table screenshot
However, for some reasons, the system doesn't allow css/styles with this code when importing the stored procedure.
Is there a way to have this query works without styles?
Thank you