sql-server - 使用 T-SQL 如何将 html 属性添加到 FOR XML PATH
问题描述
我必须在存储过程中使用 T-SQL (SQL Server) 从SELECT
. 我不确定是否/如何最好地向基本 html 表属性添加其他属性;
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')
结果:
<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>
我想补充的是:
<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>
谢谢
解决方案
推荐阅读
- azure - Jenkins 管道 - 在 ansible 和 Terraform 中引用 SSH Keys
- r - if_else 与have_labelled 列失败,因为错误的类
- javascript - 如何摆脱 v-on 处理程序中的错误:“TypeError:_vm.myFcn 不是函数”?
- javascript - 当我从下拉按钮中选择一个值时,其他值也会出现
- sas - SAS 中的 SUM() 来自同一个表 where 语句
- reactjs - NextJS getStaticProps 在开发重建时未更新
- ios - 如何在 Swift 本机代码中从 Flutter 调用参数?
- antlr - antlr4:访问者中的条件代码生成处理
- android - BLE <-> Android、iOS 设备通信是否需要绑定?
- python - 为什么str.removesuffix和str.removeprefix要复制