SQL SERVER生成HTML Table

时间:2020-03-24
本文章向大家介绍SQL SERVER生成HTML Table,主要包括SQL SERVER生成HTML Table使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

 

select 
  (select BraCode as 'td' for xml path(''), type),
  (select BraName as 'td' for xml path(''), type),
  (select BraPrefix as 'td' for xml path(''), type)
from Bra_Mst 
for xml path('tr')

 效果

<tr>
  <td>HKG</td>
  <td>Hong Kong</td>
  <td>HKG</td>
</tr>
<tr>
  <td>SHA</td>
  <td>Shanghai</td>
  <td>SHA</td>
</tr>

  

select 
  (select 'Problem' as th for xml path(''), type),
  (select 'Onset'   as th for xml path(''), type),
  (select 'Status'  as th for xml path(''), type)
union all         
select 
  (select p.ProblemType     as 'td' for xml path(''), type),
  (select p.Onset           as 'td' for xml path(''), type),
  (select p.DiagnosisStatus as 'td' for xml path(''), type)
from tblProblemList p
where p.PatientUnitNumber = @PatientUnitNumber
for xml path('tr')

  

转自: https://stackoverflow.com/questions/7086393/create-html-table-with-sql-for-xml/39487565#39487565

$flag 上一页 下一页