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

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

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

          <bdo id='mN3c3'></bdo><ul id='mN3c3'></ul>
        <tfoot id='mN3c3'></tfoot>
      2. 为 SQL 表中的每一行粉碎 XML

        时间:2023-06-07

          <bdo id='qOjoY'></bdo><ul id='qOjoY'></ul>
            <tbody id='qOjoY'></tbody>

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

          1. <tfoot id='qOjoY'></tfoot>
            <legend id='qOjoY'><style id='qOjoY'><dir id='qOjoY'><q id='qOjoY'></q></dir></style></legend>

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

                • 本文介绍了为 SQL 表中的每一行粉碎 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个包含两列、ID 和 XML 数据的表.我想为每个 ID 切碎 XML.我在 XML 中提取单个值,所有 XML 的结构都相同,我只是不确定如何遍历表并将 XML 查询应用于每一行.

                  I have a table that contains two columns, and ID, and XML data. I'd like to shred the XML for each ID. I'm pulling out a single value within the XML and all the XML is structured the same I'm just not sure how to loop through the table and apply XML query to each row.

                  我需要申请的查询如下:

                  The query I need to apply is as follows:

                  Select top 1
                  Element1 = XV.value('(.)[1]','nvarchar(32)')
                  from @xml.nodes('Parameters/Parameter/Value') as x(XV)
                  

                  所以最终结果会有两列,ID 和来自 XML 的切碎值.

                  So the end results would have two columns, ID and shredded value from XML.

                  推荐答案

                  在不了解实际 XML 以及如何将其分解以获得某些值的情况下,无法完整地回答,但这应该指出正确的方向:

                  Without any knowledge about your actual XML and how you want to shred it to get some values it is impossible to answer in completness, but this shoudl point you in the right direction:

                  返回 ID 和 XML 原样

                  Returns the ID and the XML as is

                   SELECT ID
                         ,TheXmlColumn
                   FROM YourTable
                  

                  这会从您的 XML 中返回 ID 和值

                  This returns the ID and a value out of your XML

                   SELECT ID
                         ,TheXmlColumn.value('Some XPaht','SomeType') AS SomeValueFromXML
                   FROM YourTable
                  

                  如果有更多嵌入的行,它会是这样的

                  And if there are more embedded rows it would be something like this

                   SELECT ID
                         ,nd.value('Some XPaht','SomeType') AS SomeValueFromXMLRow
                   FROM YourTable
                   OUTER APPLY TheXmlColumn.nodes('SomeXPath') AS A(nd)
                  

                  我的魔法玻璃灯泡告诉我,你可能需要这样的东西:

                  My magic glass bulb tells me, that you might need something like this:

                   SELECT ID
                         ,TheXmlColumn.value('(Parameters/Parameter/Value)[1]','nvarchar(max)') AS SomeValueFromXML
                   FROM YourTable
                  

                  这篇关于为 SQL 表中的每一行粉碎 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 SQL 编辑 XML 列.不那么结构化的 XML 下一篇:在 Sql Server 中启用 DTD 支持

                  相关文章

                  最新文章

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

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

                      • <bdo id='GXDXU'></bdo><ul id='GXDXU'></ul>
                    2. <tfoot id='GXDXU'></tfoot>
                    3. <legend id='GXDXU'><style id='GXDXU'><dir id='GXDXU'><q id='GXDXU'></q></dir></style></legend>