简体   繁体   English

如何使用 SQL Server 中其他表中的列值插入 xml 顶级属性节点

[英]How to Insert xml top level attribute nodes using a column value from other table in SQL server

I have a particular XML value, containing a namespace like this :我有一个特定的 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>

In another table, I have value:在另一个表中,我有价值:

Title             newAttr1              newAttr2
aaa               this is a sample      1
bbb               this is another       2

My goal is to have:我的目标是:

  <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"/>

I tried different ways with myXML.update, but still have errors.我用 myXML.update 尝试了不同的方法,但仍然有错误。 Can it be done?可以做到吗?

thanks in advance.提前致谢。 regards,问候,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM