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

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

    • <bdo id='N1Vol'></bdo><ul id='N1Vol'></ul>
    <tfoot id='N1Vol'></tfoot>

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

    1. 带有 for 循环的 xquery 中的 SQL Server 性能

      时间:2023-06-05
      1. <i id='8yLLq'><tr id='8yLLq'><dt id='8yLLq'><q id='8yLLq'><span id='8yLLq'><b id='8yLLq'><form id='8yLLq'><ins id='8yLLq'></ins><ul id='8yLLq'></ul><sub id='8yLLq'></sub></form><legend id='8yLLq'></legend><bdo id='8yLLq'><pre id='8yLLq'><center id='8yLLq'></center></pre></bdo></b><th id='8yLLq'></th></span></q></dt></tr></i><div id='8yLLq'><tfoot id='8yLLq'></tfoot><dl id='8yLLq'><fieldset id='8yLLq'></fieldset></dl></div>

        <legend id='8yLLq'><style id='8yLLq'><dir id='8yLLq'><q id='8yLLq'></q></dir></style></legend>

              • <bdo id='8yLLq'></bdo><ul id='8yLLq'></ul>
                <tfoot id='8yLLq'></tfoot>

                <small id='8yLLq'></small><noframes id='8yLLq'>

                  <tbody id='8yLLq'></tbody>
                本文介绍了带有 for 循环的 xquery 中的 SQL Server 性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有一个带有 xml 列的 sql 表,它保存的值类似​​于以下 xml 格式

                I have one sql table with xml column, which holds the value like following xml format

                <Security xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                  <Dacl>
                    <ACEInformation>
                      <UserName>Authenticated Users</UserName>
                      <Access>Allow</Access>
                      <IsInherited>false</IsInherited>
                      <ApplyTo>This object only</ApplyTo>
                      <Permission>List Contents</Permission>
                      <Permission>Read All Properties</Permission>
                      <Permission>Read Permissions</Permission>
                    </ACEInformation>
                    <ACEInformation>
                      <UserName>Local System</UserName>
                      <Access>Allow</Access>
                      <IsInherited>false</IsInherited>
                      <ApplyTo>This object only</ApplyTo>
                      <Permission>Read All Properties</Permission>
                      <Permission>Read Permissions</Permission>
                    </ACEInformation>
                  </Dacl>
                </Security>
                

                在这里,我想从这样的 xml 列中获取输出

                Here, I would like get output from xml column like this

                [ Allow -> Authenticated Users -> List Contents;读取所有属性;读取权限;-> 仅此对象 ]

                为了实现这一点,我使用以下 for 循环查询来连接值

                To achieve this, I am using following for loop query to join values

                SELECT  xmlColumn.query('for $item in/Security/Dacl/ACEInformation return("[",data($item/Access)
                [1],"->",data($item/UserName)[1],"->", (for $item2 in $item/Permission return concat($item2,";")),"-
                >",data($item/ApplyTo)[1],"]")').value('.','NVARCHAR(MAX)')+' ; ' From myTable
                

                查询工作正常,但给出结果花费了太多时间,对于 1000 行,需要 2 分钟...谁能帮助我提高此查询的性能?

                The query is working fine, but it takes too much time to give result, for 1000 rows, it is taking 2 mins...can anyone help me to improve performance of this query?.

                推荐答案

                select (
                       select '['+
                                 A.X.value('(Access/text())[1]', 'nvarchar(max)')+
                                 '->'+
                                 A.X.value('(UserName/text())[1]', 'nvarchar(max)')+
                                 '->'+
                                 (
                                 select P.X.value('(./text())[1]', 'nvarchar(max)')+';'
                                 from A.X.nodes('Permission') as P(X)
                                 for xml path(''), type
                                 ).value('text()[1]', 'nvarchar(max)')+
                                 '->'+
                                 A.X.value('(ApplyTo/text())[1]', 'nvarchar(max)')+
                               ']'
                       from T.xmlColumn.nodes('/Security/Dacl/ACEInformation') as A(X)
                       for xml path(''), type
                       ).value('text()[1]', 'nvarchar(max)')
                from myTable as T
                

                这篇关于带有 for 循环的 xquery 中的 SQL Server 性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用 Xquery 透视复杂的 XML 下一篇:如何在 XML 中向我的根添加常量?

                相关文章

                最新文章

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

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

                  <tfoot id='EcxF4'></tfoot>
                  • <bdo id='EcxF4'></bdo><ul id='EcxF4'></ul>

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