<i id='5VHvT'><tr id='5VHvT'><dt id='5VHvT'><q id='5VHvT'><span id='5VHvT'><b id='5VHvT'><form id='5VHvT'><ins id='5VHvT'></ins><ul id='5VHvT'></ul><sub id='5VHvT'></sub></form><legend id='5VHvT'></legend><bdo id='5VHvT'><pre id='5VHvT'><center id='5VHvT'></center></pre></bdo></b><th id='5VHvT'></th></span></q></dt></tr></i><div id='5VHvT'><tfoot id='5VHvT'></tfoot><dl id='5VHvT'><fieldset id='5VHvT'></fieldset></dl></div>

  • <tfoot id='5VHvT'></tfoot>
  • <small id='5VHvT'></small><noframes id='5VHvT'>

      <legend id='5VHvT'><style id='5VHvT'><dir id='5VHvT'><q id='5VHvT'></q></dir></style></legend>
        <bdo id='5VHvT'></bdo><ul id='5VHvT'></ul>

      1. 使用 SQL FOR XML 创建 HTML 表

        Create HTML Table with SQL FOR XML(使用 SQL FOR XML 创建 HTML 表)
          <legend id='23GQm'><style id='23GQm'><dir id='23GQm'><q id='23GQm'></q></dir></style></legend>
          <tfoot id='23GQm'></tfoot>

              <i id='23GQm'><tr id='23GQm'><dt id='23GQm'><q id='23GQm'><span id='23GQm'><b id='23GQm'><form id='23GQm'><ins id='23GQm'></ins><ul id='23GQm'></ul><sub id='23GQm'></sub></form><legend id='23GQm'></legend><bdo id='23GQm'><pre id='23GQm'><center id='23GQm'></center></pre></bdo></b><th id='23GQm'></th></span></q></dt></tr></i><div id='23GQm'><tfoot id='23GQm'></tfoot><dl id='23GQm'><fieldset id='23GQm'></fieldset></dl></div>
                <tbody id='23GQm'></tbody>

                <small id='23GQm'></small><noframes id='23GQm'>

                • <bdo id='23GQm'></bdo><ul id='23GQm'></ul>

                  本文介绍了使用 SQL FOR XML 创建 HTML 表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 SQL Server 2008 R2 中的 FOR XML 语句创建 HL7 连续性护理文档 (CCD).

                  I'm creating a HL7 Continuity of Care Document (CCD) using FOR XML statements in SQL Server 2008 R2.

                  我已经用这种方法做了很多,但这是我第一次必须在 HTML 表格中表示部分数据,这给我带来了麻烦.

                  I've done A LOT with this method, but this is the first time I have to represent part of the data in a HTML table, which is giving me trouble.

                  所以,我在表格中有以下信息:

                  So, I have the following information in a table:

                    Problem  |   Onset    | Status
                  ---------------------------------
                    Ulcer    | 01/01/2008 | Active
                    Edema    | 02/02/2005 | Active
                  

                  我正在尝试呈现以下内容

                  and I'm trying to render the following

                  <tr>
                      <th>Problem</th>
                      <th>Onset</th>
                      <th>Status</th>
                  </tr>
                  <tr>
                      <td>Ulcer</td>
                      <td>01/01/2008</td>
                      <td>Active</td>
                  </tr>
                  <tr>
                      <td>Edema</td>
                      <td>02/02/2005</td>
                      <td>Active</td>
                  </tr>
                  

                  我正在使用这个查询:

                  SELECT    p.ProblemType AS "td"
                      , p.Onset AS "td"
                      , p.DiagnosisStatus AS "td"
                  FROM tblProblemList p
                  WHERE p.PatientUnitNumber = @PatientUnitNumber
                  FOR XML PATH('tr')
                  

                  我不断收到以下信息:

                  <tr>
                    <td>Ulcer2008-01-01Active</td>
                  </tr>
                  <tr>
                    <td>Edema2005-02-02Active</td>
                  </tr>
                  

                  有人有什么建议吗?

                  推荐答案

                  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')
                  

                  要添加标题,您也可以使用 union all.

                  To add the header as well you can use union all.

                  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')
                  

                  这篇关于使用 SQL FOR XML 创建 HTML 表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Select n random rows from SQL Server table(从 SQL Server 表中随机选择 n 行)
                  SQL query to select dates between two dates(用于选择两个日期之间的日期的 SQL 查询)
                  How can I delete using INNER JOIN with SQL Server?(如何在 SQL Server 中使用 INNER JOIN 进行删除?)
                  Table Naming Dilemma: Singular vs. Plural Names(表命名困境:单数与复数名称)
                  INSERT statement conflicted with the FOREIGN KEY constraint - SQL Server(INSERT 语句与 FOREIGN KEY 约束冲突 - SQL Server)
                  Optimal way to concatenate/aggregate strings(连接/聚合字符串的最佳方式)

                • <small id='LGHs9'></small><noframes id='LGHs9'>

                            <bdo id='LGHs9'></bdo><ul id='LGHs9'></ul>
                              <tbody id='LGHs9'></tbody>
                            <i id='LGHs9'><tr id='LGHs9'><dt id='LGHs9'><q id='LGHs9'><span id='LGHs9'><b id='LGHs9'><form id='LGHs9'><ins id='LGHs9'></ins><ul id='LGHs9'></ul><sub id='LGHs9'></sub></form><legend id='LGHs9'></legend><bdo id='LGHs9'><pre id='LGHs9'><center id='LGHs9'></center></pre></bdo></b><th id='LGHs9'></th></span></q></dt></tr></i><div id='LGHs9'><tfoot id='LGHs9'></tfoot><dl id='LGHs9'><fieldset id='LGHs9'></fieldset></dl></div>
                            <legend id='LGHs9'><style id='LGHs9'><dir id='LGHs9'><q id='LGHs9'></q></dir></style></legend>
                          • <tfoot id='LGHs9'></tfoot>