我的 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>