My Xml Looks like this:
biometrictDate, biometricID,dateOfBirth, firstName, gender,
lastName, consumerUserId, MedicalHeightValue
are all columns from a table.
<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
should alone be placed in between HealthAttribute
tags which is completed using the following query:
select C.Value, C.Identifier
from TableA
outer apply (values
('MedicalHeightValue', MedicalHeightValue) ) as C(Identifier, Value)
for xml path('HealthAttribute')
Now I want the following columns alone in Assessment tag
{biometrictDate, biometricID, dateOfBirth, firstName, gender, lastName, consumerUserId}
Any help please?
New XML should look like this:
<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>