I have to use T-SQL (SQL Server) in a stored procedure to generate an html table from a SELECT
. I'm not sure if/how I might be best able to add additional attributes to the basic html table attributes;
select
(select 'ID' as 'th' for xml path(''), type),
(select 'StartDate' as 'th' for xml path(''), type),
(select 'LPlace' as 'th' for xml path(''), type)
union all
select
(select p.[Id] as 'td' for xml path(''), type),
(select p.[Created] as 'td' for xml path(''), type),
(select p.[LPlace] as 'td' for xml path(''), type)
from [SourceTbl] p
for xml path('tr'), ROOT('table')
Results:
<table>
<tr>
<th>ID</th>
<th>StartDate</th>
<th>LPlace</th>
</tr>
<tr>
<td>1</td>
<td>2019-10-13T11:36:22.0050221</td>
<td>K7</td>
</tr>
<tr>
<td>2</td>
<td>2019-03-10T13:12:07.1008696</td>
<td>J6</td>
</tr>
What I would like to add is things such as:
<table style=''font-family: Arial;font-size: 8pt;border: solid 1px #888;border-collapse: collapse;
<th style=''border: 1px solid #090F20;background-color: #0D417E;padding: 2px 0;color: #F8F8FF;font-size: 9pt;''>ID</th>
Thanks