私のXmlは次のようになります:
biometrictDate, biometricID,dateOfBirth, firstName, gender,
lastName, consumerUserId, MedicalHeightValue
テーブルのすべての列です。
<Assessment biometrictDate="20120305 08:03:00" biometricID="74330759"
dateOfBirth="1975-04-08" firstName="BRYAN" gender="M" lastName="HAYES"
consumerUserId="120004223500">
<HealthAttribute>
<Identifier>MedicalHeightValue</Identifier>
<Value>67</Value>
</HealthAttribute>
</Assessment>
MedicalHeightValue
HealthAttribute
次のクエリを使用して完了するタグの間に単独で配置する必要があります。
select C.Value, C.Identifier
from TableA
outer apply (values
('MedicalHeightValue', MedicalHeightValue) ) as C(Identifier, Value)
for xml path('HealthAttribute')
今、評価タグに次の列だけが必要です
{biometrictDate, biometricID, dateOfBirth, firstName, gender, lastName, consumerUserId}
何か助けてください。
新しい XML は次のようになります。
<Assessment biometrictDate="20120305 08:03:00" biometricID="74330759"
dateOfBirth="1975-04-08" firstName="BRYAN" gender="M" lastName="HAYES"
consumerUserId="120004223500">
<HealthAttribute>
<Identifier>MedicalHeightValue</Identifier>
<Value>67</Value>
</HealthAttribute>
</Assessment>