![](/img/trans.png)
[英]How do I select a top-level attribute of an XML column in SQL Server?
[英]How to Insert xml top level attribute nodes using a column value from other table in SQL server
我有一个特定的 XML 值,包含这样的命名空间:
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30">
<s:AttributeType name="ows_ID" rs:name="ID" rs:number="1">
<s:datatype dt:type="i4" dt:maxLength="4" />
</s:AttributeType>
<s:AttributeType name="ows_Title" rs:name="Title" rs:number="4">
<s:datatype dt:type="string" dt:maxLength="512" />
</s:AttributeType>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ows_ID="1" ows_Title="aaa" />
<z:row ows_ID="2" ows_Title="bbb />
</rs:data>
</xml>
在另一个表中,我有价值:
Title newAttr1 newAttr2
aaa this is a sample 1
bbb this is another 2
我的目标是:
<z:row ows_ID="1" ows_Title="aaa" ows_newAttr1="this is a sample" ows_newAttr2="1" />
<z:row ows_ID="2" ows_Title="bbb" ows_newAttr1="this is another" ows_newAttr2="2"/>
我用 myXML.update 尝试了不同的方法,但仍然有错误。 可以做到吗?
提前致谢。 问候,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.