【发布时间】:2018-07-02 16:26:47
【问题描述】:
我正在尝试更新包含多个命名空间的表中的特定列。我的表结构是:
+------+---------+-----------------------------------------------------------------------+
| cid | cidtype | xml_data |
+------+---------+-----------------------------------------------------------------------+
| 1001 | N | <Main xmlns:json=""http://www.samplenamespace.com/json"" > |
| | | <ID json:ValueType=""Number"">1001</ID> |
| | | <details> |
| | | <name xmlns:json=""http://www.samplenamespace.com/json"">John</name> |
| | | <age xmlns:json=""http://www.samplenamespace.com/json"">12</age> |
| | | </details> |
| | | </Main> |
| 1003 | N | <Main xmlns:json=""http://www.samplenamespace.com/json"" > |
| | | <ID json:ValueType=""Number"">1003</ID> |
| | | <details> |
| | | <name xmlns:json=""http://www.samplenamespace.com/json"">Diane</name> |
| | | <age xmlns:json=""http://www.samplenamespace.com/json"">25</age> |
| | | </details> |
| | | </Main> |
| 1004 | N | <Main xmlns:json=""http://www.samplenamespace.com/json"" > |
| | | <ID json:ValueType=""Number"">1004</ID> |
| | | <details> |
| | | <name xmlns:json=""http://www.samplenamespace.com/json"">Kippy</name> |
| | | <age xmlns:json=""http://www.samplenamespace.com/json"">26</age> |
| | | </details> |
| | | </Main> |
+------+---------+-----------------------------------------------------------------------+
在此表中,我想更改xml_data 列以将http://www.samplenamespace.com/json 命名空间删除到除<Main> 节点之外的所有子节点。
我的查询:
update #final --#final is my table
set xml_data.modify(replace('xmlns:json="http://www.samplenamespace.com/json"',' ','') where.... ) -- I don't know to access the root node here
有什么帮助吗?
【问题讨论】:
标签: sql sql-server xml sql-update