473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Xquery Help SqlServer2005

CK
I have the following XML in an XML column in a SQL 2005 Database.
<DeliveryList xmlns="http://schemas.adventure-works.com/DeliverySchedule">
<Delivery SalesOrderID="43659">
<CustomerName>Steve Schmidt</CustomerName>
<Address>6126 North Sixth Street, Rockhampton</Address>
</Delivery>
<Delivery SalesOrderID="43660">
<CustomerName>Tony Lopez</CustomerName>
<Address>6445 Cashew Street, Rockhampton</Address>
</Delivery>
</DeliveryList>

I need to query that column using the value method to retreive the address
of the first delivery. I come up with this,
SELECT
DeliveryList.value('data((/DeliveryList/Delivery/Address)[1])','nvarchar(100)')
DeliveryAddress
FROM Sales.DeliverySchedule
but it tells me
XQuery [Sales.DeliverySchedule.DeliveryList.value()]: There is no element
named 'DeliveryList'
I have tried every permutation of the path and I can not seem to get it to
work? Any ideas?


Nov 22 '06 #1
2 1381
This may help
SELECT n.value('.','nvarchar(100)') AS DeliveryAddress
FROM Sales
CROSS APPLY DeliverySchedule.nodes('declare default element namespace
"http://schemas.adventure-works.com/DeliverySchedule";
/DeliveryList/Delivery[1]/Address') D(n)

Nov 22 '06 #2
CK
Thanks! I came up with this and it works.
SELECT DeliveryList.value('declare namespace
df="http://schemas.adventure-works.com/DeliverySchedule";
(/df:DeliveryList/df:Delivery/df:Address)[1]','nvarchar(100)')
DeliveryAddress
FROM Sales.DeliverySchedule
<ma******@hotmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
This may help
SELECT n.value('.','nvarchar(100)') AS DeliveryAddress
FROM Sales
CROSS APPLY DeliverySchedule.nodes('declare default element namespace
"http://schemas.adventure-works.com/DeliverySchedule";
/DeliveryList/Delivery[1]/Address') D(n)


Nov 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tom Corcoran | last post by:
I am working to ease updating of a html page by transforming 2 xml files. I was going to use xslt for this and had bought 2 unopened books, wrox xslt and o'reilly's xslt cookbook. But am now...
0
by: Benjamin G. Jones | last post by:
I am having a very basic problem with XQuery. I want to use an XQuery API in Java (either Saxon or Qexo), and I have an XQuery expression that works as expeced from the command line if I specify...
0
by: Tony Lavinio | last post by:
Dear Stylus Studio Friends, The new year is scarcely one month old, but we already have lots to report! For starters, there's Stylus Studio 6 Release 2. The latest release of Stylus Studio...
1
by: Tobias Walter | last post by:
Hi, does anyone kown if the final release or one of the next Betas of SQL-Server 2005 will support XQuery-Statemets including the LET-Feature. Thanks, Tobias
2
by: Ken | last post by:
I am trying to query data in an XML variable and I am having trouble getting the data out in the format that I would like. Given the following XML: declare @myDoc xml set @myDoc = '<Ownership...
0
by: Stylus Studio | last post by:
DataDirect XQuery(TM) is the First Embeddable Component for XQuery That is Modeled after the XQuery API for Java(TM) (XQJ) BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies...
8
by: Clamps | last post by:
So I've been reading about XQuery, but cannot find a dll or namespace download to use the technology in vs.net 2002 or 2003. Any directions would be great. -- "If I'm the president, we're going...
3
by: Shilpa | last post by:
Where to write XQuery statements?
2
by: tammo.mueller | last post by:
Hi, I'm trying to execute a xquery statement and I get always errors. It seems that only the prolog section is giving me errors. If I want to declare a namespace the xquery processor is coming...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.