![](/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.