加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql – 使用XQUERY / Modify用varchar字段中的值替换我的XML片段

发布时间:2020-12-12 06:27:05 所属栏目:MsSql教程 来源:网络整理
导读:我有一张桌子: MyTable config as XML title as varchar(255) 在MyTable.config中,我有以下结构的XML: configuration pagetitle="myConfig" column row component id="1" type="MyPiece" title="My Title" text="junk" / /row /column/configuration 我需要
我有一张桌子:
MyTable
  config as XML
  title as varchar(255)

在MyTable.config中,我有以下结构的XML:

<configuration pagetitle="myConfig">
  <column>
    <row>
      <component id="1" type="MyPiece" title="My Title" text="junk" />
    </row>
  </column>
</configuration>

我需要一个脚本将MyTable.text的值注入我的配置XML中的组件节点的text属性中.

我知道这是错的,但我想做类似的事情:

UPDATE MyTable SET config.configuration.column.row.component.title = title

解决方法

UPDATE MyTable
   SET Config.modify('
   replace value of (/configuration/column/row/component/@title)[1]
    with sql:column("title")
   ')

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读