باستخدام Xquery/Modify لاستبدال قطعة من XML الخاص بي بالقيمة من حقل Varchar

StackOverflow https://stackoverflow.com/questions/276009

سؤال

لدي طاولة:

MyTable
  config as XML
  title as varchar(255)

في mytable.config لدي XML في الهيكل التالي:

<configuration pagetitle="myConfig">
  <column>
    <row>
      <component id="1" type="MyPiece" title="My Title" text="junk" />
    </row>
  </column>
</configuration>

أحتاج إلى برنامج نصي لحقن قيمة mytable.text في السمة النصية لعقدة المكون في config xml الخاص بي.

أعلم أن هذا خطأ ، لكني أريد أن أفعل شيئًا مشابهًا:

UPDATE MyTable SET config.configuration.column.row.component.title = title
هل كانت مفيدة؟

المحلول

UPDATE MyTable
   SET Config.modify('
   replace value of (/configuration/column/row/component/@title)[1]
    with sql:column("title")
   ')
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top