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

      <tfoot id='wPVog'></tfoot>

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

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

        如何在 SQL Server 2008 中读取 XML 列?

        时间:2023-06-07

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

                  <tbody id='xNEml'></tbody>

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

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

                • 本文介绍了如何在 SQL Server 2008 中读取 XML 列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我从未在 SQL Server 2008 中使用过 XML,我需要将一个字段列表提取到一个变量表中,你怎么做?

                  I have never used XML in SQL Server 2008, I need to extract a list of fields into a variable table how do you do it?

                  鉴于我在 XMLMain 表中有一个名为 xmldata 的列,它看起来像下面这样,如何提取 sql 中的字段列表?

                  Given that I have a column called xmldata in a XMLMain table that looks like something like below how do I extract the list of fields in sql?

                  ![在此处输入图片说明][1]

                  ![enter image description here][1]

                  <?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:SampleForm:-myXSD-2014-03-29T09-41-23" solutionVersion="1.0.0.18" productVersion="15.0.0.0" PIVersion="1.0.0.0" href="http://bipc20/sites/team-1303/FormServerTemplates/SampleForm.xsn"?>
                  <?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.4"?>
                  <my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-03-29T09:41:23" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-US">
                  <my:field1>1</my:field1>
                  <my:field2>2</my:field2>
                  <my:field3>true</my:field3>
                  <my:field4 xsi:nil="true" />
                  <my:field5 xsi:nil="true" />
                  <my:field6>4</my:field6>
                  <my:FormName>2014-04-01T15:11:47</my:FormName>
                  <my:Repeating>hi</my:Repeating>
                  <my:Repeating xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-03-29T09:41:23">hello</my:Repeating>
                  <my:Repeating xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-03-29T09:41:23">how are  you?</my:Repeating>
                  </my:myFields>
                  

                  我想以逗号分隔的形式提取重复字段的值,例如 ex.在重复中,我们有三个值(你好,你好吗?)

                  I want to extract value of Repeating field as comma separated like for ex. in Repeating we have three values (hello,how are you?)

                  有人可以帮我吗?

                  推荐答案

                  with xmlnamespaces('http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-03-29T09:41:23' as my)
                  select M.XMLData.value('(/my:myFields/my:field1/text())[1]', 'int') as field1,
                         M.XMLData.value('(/my:myFields/my:field2/text())[1]', 'int') as field2,
                         M.XMLData.value('(/my:myFields/my:field3/text())[1]', 'bit') as field3,
                         M.XMLData.value('(/my:myFields/my:FormName/text())[1]', 'datetime') as FormName,
                         (
                           select ','+R.X.value('text()[1]', 'nvarchar(max)')
                           from M.XMLData.nodes('/my:myFields/my:Repeating') as R(X)
                           for xml path(''), type
                         ).value('substring(text()[1], 2)', 'nvarchar(max)') as Repeating
                  from XMLMain as M
                  

                  结果:

                  field1      field2      field3 FormName                Repeating
                  ----------- ----------- ------ ----------------------- -----------------------
                  1           2           1      2014-04-01 15:11:47.000 hi,hello,how are  you?
                  

                  这篇关于如何在 SQL Server 2008 中读取 XML 列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:匹配嵌套 XML 节点内容的 SQL 下一篇:如何根据该 XML 中的值更新 SQL 中的 XML

                  相关文章

                  最新文章

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

                      <small id='5MdLu'></small><noframes id='5MdLu'>

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