以下のように属性を追加する方法はありますか?
前...
<Event id="CE1127552523644210147">
<Title>General Surgery Orange Rotation </Title>
<Duration>671</Duration>
<InstructionalMethod>Clinical Rotation</InstructionMethod>
</Event>
後:
<Event id="CE1127552523644210147">
<Title>General Surgery Orange Rotation </Title>
<Duration>671</Duration>
<InstructionalMethod Primary='True'>Clinical Rotation</InstructionMethod>
</Event>
元のクエリ:
select
id as '@id',
Title,
Duration,
InstructionalMethod
from MyTable
for XML PATH ('Event'), ROOT('Events')
Stackでの検索に基づいて、これを試しましたが、要素のデータが返されませんでした。
select
id as '@id',
Title,
Duration,
'True' AS 'InstructionalMethod/@Primary'
from mytable
for XML PATH ('Event'), ROOT('Events'), TYPE
結果:
<Event id="CE1127552523644210147">
<Title>General Surgery Orange Rotation </Title>
<Duration>671</Duration>
<InstructionalMethod Primary="True" />
</Event>
ご協力いただきありがとうございます。
ブライアン