<legend id='m1G74'><style id='m1G74'><dir id='m1G74'><q id='m1G74'></q></dir></style></legend>

        <tfoot id='m1G74'></tfoot>

        <small id='m1G74'></small><noframes id='m1G74'>

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

      2. 如何在 XML 中向我的根添加常量?

        时间:2023-06-05

          <bdo id='nyOwp'></bdo><ul id='nyOwp'></ul>

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

                1. 本文介绍了如何在 XML 中向我的根添加常量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  这是我生成 XML 的查询:

                  This is my query that generates an XML:

                  SELECT [a]                             a
                        ,[b]                             b
                        ,[c]                             c
                        ,[d]                             d
                        ,[e]                             e
                        ,[f]                             f
                        ,[g]                             g
                    FROM test
                    ORDER BY 1
                    FOR XML PATH('a'), ROOT('ROOT'), ELEMENTS XSINIL
                  

                  生成的 XML 以这个根开始:

                  The XML generated starts with this root:

                  我的目标是拥有一个具有更多属性的根

                  My goal is to have a root with more attributes

                  这个属性就像我想附加到我的根的常量(它们不是来自 select 的列).它们将被修复,无论选择什么

                  This attributes are like constants (thet are not columns from select) that I want to append to my root. They will be fixed, whatever will be the select

                  可以吗?

                  推荐答案

                  这是一个概念性示例.请试一试.

                  Here is a conceptual example. Please give it a shot.

                  SQL

                  -- DDL and sample data population, start
                  DECLARE @tbl TABLE (ID INT IDENTITY PRIMARY KEY, city VARCHAR(30));
                  INSERT INTO @tbl (city) VALUES
                  ('Miami'),
                  ('Orlando');
                  -- DDL and sample data population, end
                  
                  SELECT 'SIN_OPE' AS [@cod_1], '08' AS [@cod_2], '12' AS [@num_reg]
                      , 'yyyyyyyyyyyyyyyyyyy.xsd' AS [@xsi:noNamespaceSchemaLocation]
                  , (
                      SELECT * 
                      FROM @tbl
                      FOR XML PATH('r'), TYPE
                  )
                  FOR XML PATH('root'), TYPE, ELEMENTS XSINIL;
                  

                  输出

                  <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" cod_1="SIN_OPE"
                        cod_2="08" num_reg="12"
                        xsi:noNamespaceSchemaLocation="yyyyyyyyyyyyyyyyyyy.xsd">
                      <r>
                          <ID>1</ID>
                          <city>Miami</city>
                      </r>
                      <r>
                          <ID>2</ID>
                          <city>Orlando</city>
                      </r>
                  </root>
                  

                  这篇关于如何在 XML 中向我的根添加常量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:带有 for 循环的 xquery 中的 SQL Server 性能 下一篇:如何使用 sql server 在 XML 文档中获取包含具有给定

                  相关文章

                  最新文章

                  1. <small id='c4x8Z'></small><noframes id='c4x8Z'>

                      <bdo id='c4x8Z'></bdo><ul id='c4x8Z'></ul>
                    <tfoot id='c4x8Z'></tfoot>

                      <legend id='c4x8Z'><style id='c4x8Z'><dir id='c4x8Z'><q id='c4x8Z'></q></dir></style></legend>

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