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

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

        SQL 根据兄弟节点属性值选择 XML 节点

        时间:2023-06-07

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

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

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

                • 本文介绍了SQL 根据兄弟节点属性值选择 XML 节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..
                  <Findings>
                     <Finding EcinRecordID="1042893">
                        <Name>Goal Length of Stay for the ORG</Name>
                        <Selected Value="0" DisplayValue="No"/>
                     </Finding>
                     <Finding EcinRecordID="1042894">
                        <Name>Goal Length of Stay for the GRG</Name>
                        <Selected Value="1" DisplayValue="Yes"/>
                        <NoteText>3 days</NoteText>
                     </Finding>
                  </Findings>
                  

                  2 个挑战:

                  1. 选择Findings/Finding/Name 的节点值,其中Findings/Finding/Selected Value = "1"
                  2. 选择Findings/Finding/NoteText 的节点值,其中Findings/Finding/Selected Value = "1"

                  将其放入存储过程.我已经尝试了至少 3 打使用查询、存在和值的版本.可以得到Selected Value = '1',但是好像不能在Select语句中赋值对应的Name值.

                  Putting this into a stored procedure. I've tried at least 3 dozen versions using query, exists and value. I can get the whether the Selected Value = '1', but can't seem to assign the corresponding Name value in the Select statement.

                  SELECT
                     p.value('(Payments[1]/Payment[1]/PreAuthCertNumber)[1]', 'varchar(20)') AS PriorAuthNumber
                     ,qa.value('(Name[1])','varchar(255)') AS Question
                     ,qa.value('(Findings/Finding/Name)[1]','varchar(255)') AS Answer
                      FROM #ValueExample
                      CROSS APPLY XMLDocument.nodes('/OutboundDataFeed/Patient/PatientAdmission') as t(p)
                      CROSS APPLY XMLDocument.nodes('/OutboundDataFeed/Patient/PatientAdmission/CMAssessments/CMAssessment/Sections/Section/Questions/Question') as u(qa)
                  

                  谢谢!

                  推荐答案

                  declare @XML xml
                  
                  set @XML = '
                  <Findings>
                     <Finding EcinRecordID="1042893">
                        <Name>Goal Length of Stay for the ORG</Name>
                        <Selected Value="0" DisplayValue="No"/>
                     </Finding>
                     <Finding EcinRecordID="1042894">
                        <Name>Goal Length of Stay for the GRG</Name>
                        <Selected Value="1" DisplayValue="Yes"/>
                        <NoteText>3 days</NoteText>
                     </Finding>
                  </Findings>'
                  
                  select @XML.value('(/Findings/Finding[Selected/@Value = "1"]/Name/text())[1]', 'varchar(255)') as Name,
                         @XML.value('(/Findings/Finding[Selected/@Value = "1"]/NoteText/text())[1]', 'varchar(255)') as NoteText
                  

                  结果:

                  Name                                     NoteText
                  ---------------------------------------- -------------------------
                  Goal Length of Stay for the GRG          3 days
                  

                  这篇关于SQL 根据兄弟节点属性值选择 XML 节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:获取嵌套的 XML 输出 sql server 下一篇:从 Sql Server 中的 xml 中的最后一个获取第 n 个元素

                  相关文章

                  最新文章

                • <tfoot id='W0PiP'></tfoot>

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

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

                      • <bdo id='W0PiP'></bdo><ul id='W0PiP'></ul>