pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

      <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="ftpz57z" 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="x5rh77v" 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="5lrzp7t" 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>
                          主站蜘蛛池模板: 联系我们-腾龙公司上分客服微信19116098882 | 物联网卡_物联网卡购买平台_移动物联网卡办理_移动联通电信流量卡通信模组采购平台? | 空冷器|空气冷却器|空水冷却器-无锡赛迪森机械有限公司[官网] | 电动百叶窗,开窗器,电动遮阳百叶,电动开窗机生产厂家-徐州鑫友工控科技发展有限公司 | 消电检公司,消电检价格,北京消电检报告-北京设施检测公司-亿杰(北京)消防工程有限公司 | 回转炉,外热式回转窑,回转窑炉-淄博圣元窑炉工程有限公司 | 蓝莓施肥机,智能施肥机,自动施肥机,水肥一体化项目,水肥一体机厂家,小型施肥机,圣大节水,滴灌施工方案,山东圣大节水科技有限公司官网17864474793 | 合肥活动房_安徽活动板房_集成打包箱房厂家-安徽玉强钢结构集成房屋有限公司 | 三效蒸发器_多效蒸发器价格_四效三效蒸发器厂家-青岛康景辉 | 聚丙烯酰胺PAM-聚合氯化铝PAC-絮凝剂-河南博旭环保科技有限公司 巨野电机维修-水泵维修-巨野县飞宇机电维修有限公司 | 长沙一级消防工程公司_智能化弱电_机电安装_亮化工程专业施工承包_湖南公共安全工程有限公司 | 渣土车电机,太阳能跟踪器电机,蜗轮蜗杆减速电机厂家-淄博传强电机 | 济南画室培训-美术高考培训-山东艺霖艺术培训画室 | 生物颗粒燃烧机-生物质燃烧机-热风炉-生物颗粒蒸汽发生器-丽水市久凯能源设备有限公司 | 烟台条码打印机_烟台条码扫描器_烟台碳带_烟台数据采集终端_烟台斑马打印机-金鹏电子-金鹏电子 | 两头忙,井下装载机,伸缩臂装载机,30装载机/铲车,50装载机/铲车厂家_价格-莱州巨浪机械有限公司 | 防爆电机生产厂家,YBK3电动机,YBX3系列防爆电机,YBX4节防爆电机--河南省南洋防爆电机有限公司 | 泥沙分离_泥沙分离设备_泥砂分离机_洛阳隆中重工机械有限公司 | 宝元数控系统|对刀仪厂家|东莞机器人控制系统|东莞安川伺服-【鑫天驰智能科技】 | 湿地保护| 订做不锈钢_不锈钢定做加工厂_不锈钢非标定制-重庆侨峰金属加工厂 | 旗杆生产厂家_不锈钢锥形旗杆价格_铝合金电动旗杆-上海锥升金属科技有限公司 | 高光谱相机-近红外高光谱相机厂家-高光谱成像仪-SINESPEC 赛斯拜克 | 南京雕塑制作厂家-不锈钢雕塑制作-玻璃钢雕塑制作-先登雕塑厂 | 污水提升器,污水提升泵,地下室排水,增压泵,雨水泵,智能供排水控制器-上海智流泵业有限公司 | 江西自考网 | 热镀锌槽钢|角钢|工字钢|圆钢|H型钢|扁钢|花纹板-天津千百顺钢铁贸易有限公司 | 粘度计维修,在线粘度计,二手博勒飞粘度计维修|收购-天津市祥睿科技有限公司 | 冷库安装厂家_杭州冷库_保鲜库建设-浙江克冷制冷设备有限公司 | 柔性输送线|柔性链板|齿形链-上海赫勒输送设备有限公司首页[输送机] | 南方珠江-南方一线电缆-南方珠江科技电缆-南方珠江科技有限公司 南汇8424西瓜_南汇玉菇甜瓜-南汇水蜜桃价格 | 砖机托板价格|免烧砖托板|空心砖托板厂家_山东宏升砖机托板厂 | CE认证_产品欧盟ROHS-REACH检测机构-商通检测| 网站建设-网站制作-网站设计-网站开发定制公司-网站SEO优化推广-咏熠软件 | 恒温恒湿试验箱厂家-高低温试验箱维修价格_东莞环仪仪器_东莞环仪仪器 | 河北凯普威医疗器材有限公司,高档轮椅系列,推车系列,座厕椅系列,协步椅系列,拐扙系列,卫浴系列 | 隔爆型防爆端子分线箱_防爆空气开关箱|依客思 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 400电话_400电话申请_888元包年_400电话办理服务中心_400VIP网 | 液压升降货梯_导轨式升降货梯厂家_升降货梯厂家-河南东圣升降设备有限公司 | 欧必特空气能-商用空气能热水工程,空气能热水器,超低温空气源热泵生产厂家-湖南欧必特空气能公司 |