私はそのようなデータ構造を持っています:
<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>
そして、次のコード:
EXEC sp_xml_preparedocument @index OUTPUT, @XMLdoc
SELECT *
FROM OPENXML (@index, 'rootnode/group')
WITH
(
id int 'id',
anothernode varchar(30) 'anothernode'
)
結果が得られます
id | anothernode
————————————————
1 | first string
2 | third string
代わりに 4 つの文字列すべてが表示されている代わりに、この結果を表示するにはどうすればよいですか?
id | anothernode
————————————————
1 | first string
1 | second string
2 | third string
2 | fourth string