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

動態替換 XML DML 中節點的值

Dynamically replacing the value of a node in XML DML(動態替換 XML DML 中節點的值)
本文介紹了動態替換 XML DML 中節點的值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我現在正在為此苦苦掙扎:如何替換文本等于某個變量值的無類型 XML 列中的節點值?可能嗎?

I am struggling with this now: How do you replace the value of a node in an untyped XML column where the text is equal to a certain variable value? Is it possible?

我的 XML:

<attrs>
  <attr>ManualInsert</attr>
  <attr>ManualInsert2</attr>
  <attr>ManualInsert4</attr>
  <attr>ManualInsert8</attr>
</attrs>

我的嘗試:

DECLARE @OldValue Varchar(255) =  'ManualInsert'
DECLARE @NewValue Varchar(255) =  'ReplacedValue'

UPDATE
    Labels
SET
    Attributes.modify('replace value of (/attrs/attr/text())[1]
                       with
                       if ((/attrs/attr/text() = sql:variable("@OldValue")))
                       then sql:variable("@NewValue")
                       else () ')
WHERE
    Id = 2000046

消息:(0 行受影響)

DECLARE @OldValue Varchar(255) =  'ManualInsert'
DECLARE @NewValue Varchar(255) =  'ReplacedValue'

UPDATE
    Labels
SET
    Attributes.modify('replace value of (/attrs/attr[text() = sql:variable("@OldValue")])[1]
                       with sql:variable("@NewValue")')
WHERE
    Id = 2000046

留言:

Msg 2356, Level 16, State 1, Line 7
XQuery [Labels.Attributes.modify()]: The target of 'replace value of' must be a non-metadata attribute or an element with simple typed content, found 'element(attr,xdt:untyped) ?'

預期結果:

<attrs>
  <attr>ReplacedValue</attr>
  <attr>ManualInsert2</attr>
  <attr>ManualInsert4</attr>
  <attr>ManualInsert8</attr>
</attrs>

推薦答案

modify('replace value of (/attrs/attr[. = sql:variable("@OldValue")]/text())[1]
        with sql:variable("@NewValue")')

您的第二次嘗試實際上只是缺少指定應該替換的是 text() .這也可以.

Your second attempt is actually just missing to specify that it is the text() that should be replaced. This will also work.

modify('replace value of (/attrs/attr[text() = sql:variable("@OldValue")]/text())[1]
        with sql:variable("@NewValue")')

這篇關于動態替換 XML DML 中節點的值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 精品国产乱码久久久 | 久草视频观看 | 四虎永久 | 成人深夜福利网站 | 亚洲男人天堂2024 | 高清亚洲 | 伊人热久久 | 日韩国产中文字幕 | 久久神马 | 91av在线看 | 日韩中文字幕视频在线观看 | 久久久久久中文字幕 | 国产一区二区a | 亚洲欧洲视频 | 欧美精品一区在线发布 | 视频一区二区三区中文字幕 | 成人av电影在线 | 久久精品国产免费高清 | 黄色毛片在线看 | 久久久国产精品入口麻豆 | 色网站在线免费观看 | 伊人免费观看视频 | 亚洲最大福利网 | 欧美成人免费在线视频 | 毛片免费在线 | 中文在线a在线 | 黑人巨大精品欧美一区二区免费 | 美女天天干 | 精品成人在线视频 | 精品视频免费 | 国产一区久久 | 无码日韩精品一区二区免费 | 狠狠干综合视频 | 91在线精品视频 | 亚洲免费一| 欧美a级成人淫片免费看 | 国产中文原创 | 麻豆av片 | 久久国产美女视频 | 一区二区av | 久久精品国产亚洲一区二区三区 |