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

  • <legend id='XfaaB'><style id='XfaaB'><dir id='XfaaB'><q id='XfaaB'></q></dir></style></legend>

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

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

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

      1. 在忽略命名空间的同时查询 XML?

        时间:2023-06-07

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

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

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

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

                    <tbody id='jaor0'></tbody>
                  <tfoot id='jaor0'></tfoot>

                  本文介绍了在忽略命名空间的同时查询 XML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我试图在忽略命名空间的同时查询 XML,因为结果集有多个命名空间.我已经到了 DataSets 节点,但我不知道如何取出多个 DataSourceName/CommandType/CommandText.理想情况下,我想要:

                  I'm trying to query XML while ignoring namespaces, because the result set has multiple namespaces. I've gotten to the DataSets node, but I can't figure out how to get out the multiple DataSourceName/CommandType/CommandText. Ideally I want:

                  DataSetName   DataSourceName   CommandType      CommandText
                  SQLDS         SQLDS            StoredProcedure  ReportProc_aaaaa
                  SQLDS         SQLDS            StoredProcedure  ReportProc_lalala
                  

                  非常感谢帮助.

                  DECLARE @xmltable TABLE (myxml XML)
                  INSERT INTO @xmltable 
                  SELECT   
                  '<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
                    <DataSources>
                      <DataSource Name="SQLDS">
                        <rd:DataSourceID>32e83b35-434d-4808-b685-ada14accd0e7</rd:DataSourceID>
                        <DataSourceReference>SQLDS</DataSourceReference>
                      </DataSource>
                    </DataSources>
                    <DataSets>
                      <DataSet Name="SQLDS">
                        <Query>
                          <DataSourceName>SQLDS</DataSourceName>
                          <CommandType>StoredProcedure</CommandType>
                          <CommandText>ReportProc_ServerPerformanceGroup</CommandText>
                        </Query>
                      </DataSet>
                      <DataSet Name="GroupDetails">
                        <Query>
                          <DataSourceName>SQLDS</DataSourceName>
                          <CommandType>StoredProcedure</CommandType>
                          <CommandText>ReportProc_lalala</CommandText>
                        </Query>
                      </DataSet>
                    </DataSets>
                  </Report>'
                  
                  SELECT myxml.value('(/*:Report/*:DataSets)[1]','varchar(100)') FROM @xmltable
                  

                  推荐答案

                  使用 nodes() 方法(xml 数据类型) 将 yoru XML 分解为行并使用 value() 方法(xml 数据类型) 从 XML 中获取特定值.

                  Use nodes() Method (xml Data Type) to shred yoru XML to rows and use value() Method (xml Data Type) to get specific values from the XML.

                  select T1.N.value('@Name', 'nvarchar(128)') as DataSetName,
                         T2.N.value('(*:DataSourceName/text())[1]', 'nvarchar(128)') as DataSourceName,
                         T2.N.value('(*:CommandType/text())[1]', 'nvarchar(128)') as CommandType,
                         T2.N.value('(*:CommandText/text())[1]', 'nvarchar(max)') as CommandText
                  from @xmltable as T
                    cross apply T.myxml.nodes('/*:Report/*:DataSets/*:DataSet') as T1(N)
                    cross apply T1.N.nodes('*:Query') as T2(N)
                  

                  SQL 小提琴

                  这篇关于在忽略命名空间的同时查询 XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:即使表达式值为空,如何强制执行 xmlforest creat 下一篇:SQL Server 生成带有通用字段元素的 XML

                  相关文章

                  最新文章

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

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

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

                  2. <legend id='AKGt4'><style id='AKGt4'><dir id='AKGt4'><q id='AKGt4'></q></dir></style></legend>
                    <tfoot id='AKGt4'></tfoot>