【发布时间】:2011-11-04 16:58:58
【问题描述】:
我有一个这样的数据结构:
<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
我怎样才能让它显示这个结果而不是显示所有四个字符串?
id | anothernode
————————————————
1 | first string
1 | second string
2 | third string
2 | fourth string
【问题讨论】:
标签: sql sql-server sql-server-2008 openxml sql-server-openxml