如何在Sql Server 2005中使用Xquery检索xml数据? [英] how to retrieve xml data using Xquery in Sql server 2005 ?

查看:87
本文介绍了如何在Sql Server 2005中使用Xquery检索xml数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请帮忙告知如何在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆