![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi I'm trying to build an XML document from a relational schema. A lot of it works well, but I've having trouble building sub-elements which have attributes as well as data. A simplified example is: Tables Name NameId Type 1 person NamePart NameId Type Value 1 given Chloe 1 family Crowder What I want is name type="person"><namePart type="given">Chloe</namePart><namePart type="family">Crowder</namePart></name |
#3
| |||
| |||
|
|
Chloe C wrote: Hi I'm trying to build an XML document from a relational schema. A lot of it works well, but I've having trouble building sub-elements which have attributes as well as data. A simplified example is: Tables Name NameId Type 1 person NamePart NameId Type Value 1 given Chloe 1 family Crowder What I want is name type="person"><namePart type="given">Chloe</namePart><namePart type="family">Crowder</namePart></name SELECT n.type as "@type", (SELECT np.type AS "@type", np.value as "text()" FROM NamePart np WHERE np.NameId = n.NameId FOR XML PATH(N'namePart'), TYPE) FROM Name n FOR XML PATH(N'name'), TYPE |
![]() |
| Thread Tools | |
| Display Modes | |
| |