• <small id='Ncove'></small><noframes id='Ncove'>

        <tfoot id='Ncove'></tfoot>

        <legend id='Ncove'><style id='Ncove'><dir id='Ncove'><q id='Ncove'></q></dir></style></legend>
          <bdo id='Ncove'></bdo><ul id='Ncove'></ul>
      1. <i id='Ncove'><tr id='Ncove'><dt id='Ncove'><q id='Ncove'><span id='Ncove'><b id='Ncove'><form id='Ncove'><ins id='Ncove'></ins><ul id='Ncove'></ul><sub id='Ncove'></sub></form><legend id='Ncove'></legend><bdo id='Ncove'><pre id='Ncove'><center id='Ncove'></center></pre></bdo></b><th id='Ncove'></th></span></q></dt></tr></i><div id='Ncove'><tfoot id='Ncove'></tfoot><dl id='Ncove'><fieldset id='Ncove'></fieldset></dl></div>
      2. 选择 SQL 查询以从 ntext 列中获取 xml 节点值?

        时间:2023-06-07
        <tfoot id='a1yYz'></tfoot>

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

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

                  本文介绍了选择 SQL 查询以从 ntext 列中获取 xml 节点值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想从包含基于 where 子句查询另一个 xml 节点值的 xml 的 NTEXT 列中获取一个 xml 节点值.RDBMS 类型:Microsoft SQL Server T-SQL这里:我想根据 StoreId where 子句值获取代码节点值.我如何得到它?输入:100输出:ABCDE

                  I want to get one xml node value from NTEXT column which contains xml based on where clause quering on another xml node value. RDBMS Type: Microsoft SQL Server T-SQL Here: I want to get Code node value based on StoreId where clause value. How do I get it? Input: 100 Output:ABCDE

                  例如:

                  <root>
                    <StoreProfile>
                      <General>
                       <StoreId>100</StoreId>
                       <Code>ABCDE</Code>
                      </General>
                    </StoreProfile>
                  </root>
                  

                  推荐答案

                  如果您使用的是 SQL Server 2005 或 2008,您可以像这样使用 XQuery:

                  If you are using SQL Server 2005 or 2008 you can use XQuery like so:

                  有关 XQuery 的更多信息,请参阅 XQuery 语言参考

                  For more on XQuery see XQuery Language Reference

                  DECLARE @storeId INT
                  SET @storeId = 100
                  
                  CREATE TABLE #TestTable
                  (
                      xmlColumn NTEXT
                  )
                  
                  INSERT INTO #TestTable (xmlColumn) Values('<root><StoreProfile><General><StoreId>100</StoreId><Code>ABCDE</Code></General></StoreProfile></root>')
                  INSERT INTO #TestTable (xmlColumn) Values('<root><StoreProfile><General><StoreId>200</StoreId><Code>FGHIJ</Code></General></StoreProfile></root>')
                  
                  SELECT 
                      StoreProfile.value('Code[1]', 'nvarchar(10)') as Code 
                  FROM #TestTable
                      CROSS APPLY (SELECT CAST(xmlColumn AS XML)) AS A(B) 
                      CROSS APPLY A.B.nodes('//root/StoreProfile/General[StoreId = sql:variable("@storeId")]') AS StoreProfiles(StoreProfile)
                  
                  DROP TABLE #TestTable
                  

                  这篇关于选择 SQL 查询以从 ntext 列中获取 xml 节点值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 Oracle 中通过 XPath 获取第一个元素 下一篇:更新语句上的 SQLite 3.8.2 异常

                  相关文章

                  最新文章

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

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

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