如何在Sql Server 2005中使用Xquery检索xml数据? [英] how to retrieve xml data using Xquery in Sql server 2005 ?
问题描述
请帮忙告知如何在sql server 2005中使用Xquery检索xml数据吗?
范例:--->如下所示的xml文件
< root>
< id> 1
<名称>名称1
< id> 2
<名称> Name2
我正在使用以下查询
从tblTextToXml中选择xmlField.query(''data(/root/Name)'')AS名称
但是,结果显示如下所示
名称
~~~~~~
名称1名称2
但是,我想要下面的结果
名称
~~~~~~
名称1
名称2
请建议...
Hi,
Please help to advise how can we retrive xml data using Xquery In sql server 2005 ?
Example : ---> xml file like below
<root>
<id> 1
<name> Name1
<id> 2
<name> Name2
I am using below Query
select xmlField.query(''data(/root/Name)'') AS Names from tblTextToXml
But, Result Displaying like below
Names
~~~~~~
Name1 Name2
But, i want result like below
Names
~~~~~~
Name1
Name2
please advise...
推荐答案
您可以使用选项EXPLICIT
来形成XML.有一个基于AdventureWorks数据库的示例此处 [
You can use the option EXPLICIT
to form your XML. There''s an example based on the AdventureWorks database here[^].
这篇关于如何在Sql Server 2005中使用Xquery检索xml数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!