Parsing OpenXML con múltiples elementos del mismo nombre
Tengo una estructura de datos como tal:
<rootnode>
<group>
<id>1</id>
<anothernode>first string</anothernode>
<anothernode>second string</anothernode>
</group>
<group>
<id>2</id>
<anothernode>third string</anothernode>
<anothernode>fourth string</anothernode>
</group>
</rootnode>
Y el siguiente código:
EXEC sp_xml_preparedocument @index OUTPUT, @XMLdoc
SELECT *
FROM OPENXML (@index, 'rootnode/group')
WITH
(
id int 'id',
anothernode varchar(30) 'anothernode'
)
que me da el resultado
id | anothernode
————————————————
1 | first string
2 | third string
¿Cómo puedo hacer que muestre este resultado en lugar de mostrar las cuatro cadenas?
id | anothernode
————————————————
1 | first string
1 | second string
2 | third string
2 | fourth string