Generating html table with stored procedure with some conditions
<p>I am working on tsql to create an html report. The existing table is a list of error_codes organized as follows:</p>

<p><strong>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</strong></p>

<pre><code>| 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     |
 -----------------------------------------------------------------
</code></pre>

<p>I need to display that table in HTML format and make every header with its child error entries in a separate <code>&lt;tr&gt;</code></p>

<p>I used the following code:</p>

<pre><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') 
)
</code></pre>

<p>The results were very good, 
<a href="https://i.stack.imgur.com/D4dbP.png" rel="nofollow noreferrer">table screenshot</a></p>

<p>However, for some reasons, the system doesn't allow css/styles with this code when importing the stored procedure.</p>

<p>Is there a way to have this query works without styles?</p>

<p>Thank you</p>