Click here to Skip to main content
14,971,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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...
Posted

1 solution

You can use the option EXPLICIT to form your XML. There's an example based on the AdventureWorks database here[^].
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900