久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <small id='4LCpx'></small><noframes id='4LCpx'>

      • <bdo id='4LCpx'></bdo><ul id='4LCpx'></ul>

    1. <tfoot id='4LCpx'></tfoot>

    2. <i id='4LCpx'><tr id='4LCpx'><dt id='4LCpx'><q id='4LCpx'><span id='4LCpx'><b id='4LCpx'><form id='4LCpx'><ins id='4LCpx'></ins><ul id='4LCpx'></ul><sub id='4LCpx'></sub></form><legend id='4LCpx'></legend><bdo id='4LCpx'><pre id='4LCpx'><center id='4LCpx'></center></pre></bdo></b><th id='4LCpx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4LCpx'><tfoot id='4LCpx'></tfoot><dl id='4LCpx'><fieldset id='4LCpx'></fieldset></dl></div>
    3. <legend id='4LCpx'><style id='4LCpx'><dir id='4LCpx'><q id='4LCpx'></q></dir></style></legend>
    4. 如何根據該 XML 中的值更新 SQL 中的 XML

      How to Update XML in SQL based on values in that XML(如何根據該 XML 中的值更新 SQL 中的 XML)
      <legend id='bokOp'><style id='bokOp'><dir id='bokOp'><q id='bokOp'></q></dir></style></legend>

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

          <tfoot id='bokOp'></tfoot>

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

            <tbody id='bokOp'></tbody>
          • <bdo id='bokOp'></bdo><ul id='bokOp'></ul>
              1. 本文介紹了如何根據該 XML 中的值更新 SQL 中的 XML的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我必須根據該 XML 的某些條件更新表的 XML.示例 XML:

                I have to update XML of table based on some conditions of that XML. Sample XML:

                <CountryValues>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>2</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>3</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>4</Month>
                    <PlaceValue>10</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Australia</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Australia</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Australia</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>4</PlaceValue>        
                  </CountryRow>
                 </CountryValues>
                

                每個國家/地區可以有多個地方.我必須根據 Country 和 Places 進行分組,然后我必須將 PlaceValues 更新為 null for PlaceValue = 0 除了 0 緊接在 PlaceValue > 1 之前.此示例中的示例,對于 Country = Brazil 和 PlaceName = 1,PlaceValue forMonth1 到 Month2 將為 Null 但 Month3 將保持為 0 作為其前一個 Month4 大于 0.

                Each Country can have multiple Places. I have to group on the basis of Country and Places, then I have to update PlaceValues to null for PlaceValue = 0 except 0 which is immediately preceding PlaceValue > 1. Example in this sample, for Country = Brazil and PlaceName = 1, PlaceValue for Month1 to Month2 will be Null but Month3 will remain 0 as its preceding Month4 which is greate than 0.

                推薦答案

                基本上,我看到了兩種處理方法.首先 - 將 xml 拆分為 sql 表/派生表,完成您的工作,然后再次組合成 xml.

                Basically, I see 2 ways of dealing with this. First - split xml to sql table/derived table, do your work and then combine into xml again.

                declare @data xml = 
                '<CountryValues>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>2</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>3</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>4</Month>
                    <PlaceValue>10</PlaceValue>        
                  </CountryRow>
                 </CountryValues>'
                
                ;with cte as (
                    select
                        t.c.value('CountryName[1]', 'nvarchar(max)') as CountryName,
                        t.c.value('PlaceName[1]', 'nvarchar(max)') as PlaceName,
                        t.c.value('Month[1]', 'int') as [Month],
                        t.c.value('PlaceValue[1]', 'int') as PlaceValue
                    from @data.nodes('CountryValues/CountryRow') as t(c)
                )
                select
                    c1.CountryName,
                    c1.PlaceName,
                    c1.[Month],
                    case
                        when c1.PlaceValue = 0 and isnull(c2.PlaceValue, 0) <= 1 then null
                        else c1.PlaceValue
                    end as PlaceValue
                from cte as c1
                    left outer join cte as c2 on c2.CountryName = c1.CountryName and c2.PlaceName = c1.PlaceName and c2.[Month] = c1.[Month] + 1
                for xml path('CountryRow'), root('CountryValues')
                
                ----------------------------------
                <CountryValues>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>2</Month>
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>3</Month>
                    <PlaceValue>0</PlaceValue>
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>4</Month>
                    <PlaceValue>10</PlaceValue>
                  </CountryRow>
                </CountryValues>
                

                第二種方法是在 xml 本身中使用 xquery.

                Second way would be to use xquery inside the xml itself.

                答案實際上取決于您所說的緊接在 PlaceValue > 1 之前"是什么意思.我在這里假設這意味著 - 值 > 1 的月份之前的月份.

                The answer is really depends on what do you mean by "immediately preceding PlaceValue > 1". I've assumed here that this means - month right before month with value > 1.

                這篇關于如何根據該 XML 中的值更新 SQL 中的 XML的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產品、類別和元數據的 SQL 查詢 woocommerce/wordpress)
                Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 ExecuteNonQuery()?)
                How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                • <legend id='yVz9v'><style id='yVz9v'><dir id='yVz9v'><q id='yVz9v'></q></dir></style></legend>
                    <tbody id='yVz9v'></tbody>

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

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

                      • <tfoot id='yVz9v'></tfoot>
                          主站蜘蛛池模板: 免费网站国产 | 一区精品视频在线观看 | 521av网站| 成人黄色av网址 | 欧美成人精品在线观看 | 欧美综合久久久 | 久久精品国产久精国产 | 日本久久久久久久久 | 中文字幕一区二区三区乱码在线 | 黄色一级片视频 | 青青久草| 日韩毛片网 | 中文字幕视频在线观看 | 国产乱码精品一区二区三区五月婷 | 日本超碰| 九九精品在线 | 亚州毛片 | 日本一二区视频 | 免费看91 | 国产精品久久久久久久久久东京 | 91久久国产综合久久91精品网站 | 夜夜操天天艹 | 亚洲激情视频在线 | 日日骚av | 欧美日韩综合 | 久久精品 | 成人在线观看免费 | 欧美亚洲国产成人 | 欧美日韩综合 | 亚洲国产精品一区 | 久久看看 | 欧美国产日韩一区二区三区 | 中文字幕韩在线第一页 | www精品| 国产精品91久久久久久 | 精国产品一区二区三区四季综 | 91精品国产综合久久久久久丝袜 | 一级片网址 | 亚洲精品自拍 | 欧美日韩一区二区三区四区 | 久久国产亚洲 |