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

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

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

        <legend id='VcyRU'><style id='VcyRU'><dir id='VcyRU'><q id='VcyRU'></q></dir></style></legend>
      1. 使用 SQL 在 XML 中插入節點

        Inserting node in XML using SQL(使用 SQL 在 XML 中插入節點)
        <tfoot id='N5Ca5'></tfoot>
          <tbody id='N5Ca5'></tbody>
        <i id='N5Ca5'><tr id='N5Ca5'><dt id='N5Ca5'><q id='N5Ca5'><span id='N5Ca5'><b id='N5Ca5'><form id='N5Ca5'><ins id='N5Ca5'></ins><ul id='N5Ca5'></ul><sub id='N5Ca5'></sub></form><legend id='N5Ca5'></legend><bdo id='N5Ca5'><pre id='N5Ca5'><center id='N5Ca5'></center></pre></bdo></b><th id='N5Ca5'></th></span></q></dt></tr></i><div class="5bpplp5" id='N5Ca5'><tfoot id='N5Ca5'></tfoot><dl id='N5Ca5'><fieldset id='N5Ca5'></fieldset></dl></div>

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

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

                • <bdo id='N5Ca5'></bdo><ul id='N5Ca5'></ul>
                  本文介紹了使用 SQL 在 XML 中插入節點的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有以下 XML:

                  創建表#temp(cid int,xml_data xml)插入 cid值(1001,'<主><name>''John doe''</name><年齡>15</年齡></主要>')

                  我想根據一個簡單的參數條件向這個 XML 添加一個額外的節點:

                  所需的輸出:

                  <name>John doe</name><type>Q</type><年齡>15</年齡></主要>

                  代碼:

                  select case when @type = 'Q' then更新#tempSET Main.modify('insert  into(/主要的)')走

                  我收到語法錯誤.任何幫助!

                  更新:

                  我在代碼中實施了建議的解決方案,但出現以下錯誤.錯過了一些愚蠢的東西!

                   更新 #temp設置 xml_data =案件當@type = 'G'然后 xml_data.modify('insert G into (/Main)[1]');當@type = 'Q'然后 xml_data.modify('insert Q into (/Main)[1]');結尾

                  我收到'XML 數據類型方法'修改'的錯誤使用.在這種情況下需要一個非突變方法.錯誤

                  解決方案

                  不需要任何復雜的麻煩.只需根據需要插入所需的節點:

                  UPDATE #temp SET xml_data.modify('insert Q into (/Main)[1]');

                  使用 as firstas lastbefore/after 允許您指定節點的位置.下面將新節點直接放在 之后:

                  UPDATE #temp SET xml_data.modify('insert Q after (/Main/name)[1]');

                  更新您關于更新語句的問題

                  你的陳述有幾個缺陷:

                  <塊引用>

                  更新#temp設置 xml_data =案件當@type = 'G'然后 xml_data.modify('insert G into (/Main)[1]');當@type = 'Q'然后 xml_data.modify('insert Q into (/Main)[1]');結尾

                  您不能使用語法 SET xmlColumn = xmlColumn.modify().您必須使用 SET xmlColumn.modify(),而且分號無論如何都會破壞這一點.

                  老實說,我覺得這很復雜,試試這個:

                  DECLARE @type VARCHAR(1)='Q'UPDATE #temp SET xml_data.modify('insert {sql:variable("@type")} into (/Main)[1]');

                  這將創建一個新節點 content</type>,其中的內容從變量 @type 中取出.

                  I have the below XML:

                  create table #temp(cid int,xml_data xml)
                  insert into cid
                  values(1001,
                       '<Main>
                          <name>''John doe''</name>
                          <age>15</age>
                      </Main>')
                  

                  I want to add an additional node to this XML based on a simple parametric condition:

                  desired output:

                  <Main>
                      <name>John doe</name>
                      <type>Q</type>
                      <age>15</age>
                  </Main>
                  

                  code:

                  select case when @type = 'Q' then
                      UPDATE #temp
                      SET Main.modify('insert <type = 'Q'> into 
                          (/Main)')
                      GO
                  

                  I am getting syntax error. Any help!

                  UPDATE:

                  I implemented the suggested solution in my code and I'm getting below error. Missing out something silly!

                   UPDATE #temp
                           SET xml_data = 
                              case
                                  when @type = 'G' 
                                  then xml_data.modify('insert <type>G</type> into (/Main)[1]');
                                  when @type = 'Q' 
                                  then xml_data.modify('insert <type>Q</type> into (/Main)[1]'); end
                  

                  I am getting 'Incorrect use of the XML data type method 'modify'. A non-mutator method is expected in this context.' error

                  解決方案

                  No need for any complicated hassel. Just insert the node you want as you want it:

                  UPDATE #temp SET xml_data.modify('insert <type>Q</type> into (/Main)[1]');
                  

                  Using as first, as last or before / after allows you to specify the node's position. The following will place the new node directly after <name>:

                  UPDATE #temp SET xml_data.modify('insert <type>Q</type> after (/Main/name)[1]');
                  

                  UPDATE Your question about an update-statement

                  Your statement has several flaws:

                  UPDATE #temp
                       SET xml_data = 
                          case
                              when @type = 'G' 
                              then xml_data.modify('insert <type>G</type> into (/Main)[1]');
                              when @type = 'Q' 
                              then xml_data.modify('insert <type>Q</type> into (/Main)[1]'); 
                           end
                  

                  You cannot use the syntax SET xmlColumn = xmlColumn.modify(). You have to use SET xmlColumn.modify(), Furthermore the semicolons are breaking this anyway.

                  To be honest, I think this is to complicated, try this:

                  DECLARE @type VARCHAR(1)='Q'
                  UPDATE #temp SET xml_data.modify('insert <type>{sql:variable("@type")}</type> into (/Main)[1]');
                  

                  This will create a new node <type>content</type>, with a content taken out ot the variable @type.

                  這篇關于使用 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?)

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

                    <legend id='D0Ddp'><style id='D0Ddp'><dir id='D0Ddp'><q id='D0Ddp'></q></dir></style></legend>
                      <bdo id='D0Ddp'></bdo><ul id='D0Ddp'></ul>

                        <tbody id='D0Ddp'></tbody>

                      1. <tfoot id='D0Ddp'></tfoot>
                      2. <i id='D0Ddp'><tr id='D0Ddp'><dt id='D0Ddp'><q id='D0Ddp'><span id='D0Ddp'><b id='D0Ddp'><form id='D0Ddp'><ins id='D0Ddp'></ins><ul id='D0Ddp'></ul><sub id='D0Ddp'></sub></form><legend id='D0Ddp'></legend><bdo id='D0Ddp'><pre id='D0Ddp'><center id='D0Ddp'></center></pre></bdo></b><th id='D0Ddp'></th></span></q></dt></tr></i><div class="bpbjx5r" id='D0Ddp'><tfoot id='D0Ddp'></tfoot><dl id='D0Ddp'><fieldset id='D0Ddp'></fieldset></dl></div>
                          1. 主站蜘蛛池模板: 快速门厂家批发_PVC快速卷帘门_高速门_高速卷帘门-广州万盛门业 快干水泥|桥梁伸缩缝止水胶|伸缩缝装置生产厂家-广东广航交通科技有限公司 | 硫化罐-电加热蒸汽硫化罐生产厂家-山东鑫泰鑫智能装备有限公司 | 超声波清洗机_细胞破碎仪_实验室超声仪器_恒温水浴-广东洁盟深那仪器 | 定坤静电科技静电消除器厂家-除静电设备 | 不锈钢酒柜|恒温酒柜|酒柜定制|酒窖定制-上海啸瑞实业有限公司 | 煤机配件厂家_刮板机配件_链轮轴组_河南双志机械设备有限公司 | 江苏密集柜_电动_手动_移动_盛隆柜业江苏档案密集柜厂家 | 冷轧机|两肋冷轧机|扁钢冷轧机|倒立式拉丝机|钢筋拔丝机|收线机-巩义市华瑞重工机械制造有限公司 | 黑龙江京科脑康医院-哈尔滨精神病医院哪家好_哈尔滨精神科医院排名_黑龙江精神心理病专科医院 | 挤奶设备过滤纸,牛奶过滤纸,挤奶机过滤袋-济南蓝贝尔工贸有限公司 | 胶原检测试剂盒,弹性蛋白检测试剂盒,类克ELISA试剂盒,阿达木单抗ELISA试剂盒-北京群晓科苑生物技术有限公司 | 门禁卡_智能IC卡_滴胶卡制作_硅胶腕带-卡立方rfid定制厂家 | 户外健身路径_小区健身器材_室外健身器材厂家_价格-浩然体育 | 合肥汽车充电桩_安徽充电桩_电动交流充电桩厂家_安徽科帝新能源科技有限公司 | 双杰天平-国产双杰电子天平-美国双杰-常熟双杰仪器 | 自动化改造_智虎机器人_灌装机_贴标机-上海圣起包装机械 | 长沙一级消防工程公司_智能化弱电_机电安装_亮化工程专业施工承包_湖南公共安全工程有限公司 | 挤出机_橡胶挤出机_塑料挤出机_胶片冷却机-河北伟源橡塑设备有限公司 | COD分析仪|氨氮分析仪|总磷分析仪|总氮分析仪-圣湖Greatlake | Akribis直线电机_直线模组_力矩电机_直线电机平台|雅科贝思Akribis-杭州摩森机电科技有限公司 | 恒温槽_恒温水槽_恒温水浴槽-上海方瑞仪器有限公司 | 物联网卡_物联网卡购买平台_移动物联网卡办理_移动联通电信流量卡通信模组采购平台? | 车充外壳,车载充电器外壳,车载点烟器外壳,点烟器连接头,旅行充充电器外壳,手机充电器外壳,深圳市华科达塑胶五金有限公司 | 环境模拟实验室_液体-气体控温机_气体控温箱_无锡双润冷却科技有限公司 | 分子蒸馏设备(短程分子蒸馏装置)_上海达丰仪器 | 美侍宠物-专注宠物狗及宠物猫训练|喂养|医疗|繁育|品种|价格 | 探伤仪,漆膜厚度测试仪,轮胎花纹深度尺厂家-淄博创宇电子 | 淘剧影院_海量最新电视剧,免费高清电影随心观看 | 立式硫化罐-劳保用品硫化罐-厂家直销-山东鑫泰鑫硫化罐厂家 | 京港视通报道-质量走进大江南北-京港视通传媒[北京]有限公司 | 接地电阻测试仪[厂家直销]_电缆故障测试仪[精准定位]_耐压测试仪-武汉南电至诚电力设备 | 科普仪器菏泽市教育教学仪器总厂| 合肥汽车充电桩_安徽充电桩_电动交流充电桩厂家_安徽科帝新能源科技有限公司 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 碳纤维复合材料制品生产定制工厂订制厂家-凯夫拉凯芙拉碳纤维手机壳套-碳纤维雪茄盒外壳套-深圳市润大世纪新材料科技有限公司 | 耐磨焊丝,堆焊焊丝,耐磨药芯焊丝,碳化钨焊丝-北京耐默公司 | 合肥升降机-合肥升降货梯-安徽升降平台「厂家直销」-安徽鼎升自动化科技有限公司 | 真丝围巾|真丝丝巾|羊绒围巾|围巾品牌|浙江越缇围巾厂家定制 | 中直网_行业门户-行业人专业的交流平台!| 哈尔滨发电机,黑龙江柴油发电机组-北方星光 | 一体化隔油提升设备-餐饮油水分离器-餐厨垃圾处理设备-隔油池-盐城金球环保产业发展有限公司 |