【发布时间】:2013-01-29 09:23:46
【问题描述】:
从 Sql Server 2008 的 xml 字段中删除具有缺失属性的根节点的所有子节点的正确方法是什么?
我的 Xml 看起来像这样,我想删除 <root> 的所有未指定 ln 属性的子节点
<root>
<title />
<title />
<questionphrase ln="nl">
<xhtml />
</questionphrase>
<questionphrase ln="en">
<xhtml />
</questionphrase>
<information ln="nl">
<xhtml />
</information>
<information ln="en">
<xhtml />
</information>
<title />
<title ln="en">
value
</title>
<label ln="en">
value
</label>
<title />
<title />
</root>
删除后的xml应该是这样的
<root>
<questionphrase ln="nl">
<xhtml />
</questionphrase>
<questionphrase ln="en">
<xhtml />
</questionphrase>
<information ln="nl">
<xhtml />
</information>
<information ln="en">
<xhtml />
</information>
<title ln="en">
value
</title>
<label ln="en">
value
</label>
</root>
【问题讨论】:
-
您是想在表格中永久删除它们,还是在
SELECT期间隐藏它们? -
我想完全删除它们,损坏的数据只会导致开销。
标签: sql sql-server sql-server-2008 tsql sql-delete