Parar OpenXML com vários elementos com o mesmo nome
Tenho uma estrutura de dados 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>
E o seguinte 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 dá o resultado
id | anothernode
————————————————
1 | first string
2 | third string
Como posso mostrar esse resultado em vez de mostrar todas as quatro string
id | anothernode
————————————————
1 | first string
1 | second string
2 | third string
2 | fourth string