(SELECT TOP 1 '01' AS '@language', 'a description' as 'data()' FROM @tmpData AS FOR XML PATH('description'),ROOT('course'),TYPE),
(SELECT TOP 1 '2016-CRS' AS '@code' FROM @tmpData as t FOR XML PATH('course'),TYPE),
這說明:
<course>
<description language="01">a description</description>
</course>
<course code="2016-CRS" />
但我真正需要的是:
<course code="2016-CRS">
<description language="01">a description</description>
</course>
我知道這很簡單,但我無法實現。感謝任何見解!
什麼是@ tmpData?你不使用任何值... – Shnugo