有没有办法添加如下附加属性?
前...
<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>
谢谢你的帮助。
布赖恩