I have a resource table which has an XMLPropertyBag as an XML column...which has the below format.I want to Query the EndDate for all resources.
<Resource xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/testdb.Data.DataContexts">
I used the below query..but not getting the values..getting all empty records.
SELECT XMLPropertyBag.query('/Resource/EndDate') from dbo.Resources
Please let me know if anyone has a clue.I am using SqlServer 2008.
Thanks a lot..
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
1 reply Latest Post - 2011-10-26T06:45:20Z by SystemAdmin
Pinned topic Xpath for reading data...
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2011-10-26T06:45:20Z at 2011-10-26T06:45:20Z by SystemAdmin
SystemAdmin 110000D4XK1391 PostsACCEPTED ANSWER
Re: Xpath for reading data...2011-10-26T06:45:20Z in response to sree.koneruThat is sort of faq, that you've to understand the meaning of namespace qualified name and default namespace...
The query should look something like this.
SELECT XMLPropertyBag.query( ' declare default element namespace "http://schemas.datacontract.org/2004/07/testdb.Data.DataContexts"; data(/Resource/EndDate) ') as EndDate from dbo.Resources
Or, for illustration using namespace prefix.
SELECT XMLPropertyBag.query( ' declare namespace ns1= "http://schemas.datacontract.org/2004/07/testdb.Data.DataContexts"; data(/ns1:Resource/ns1:EndDate) ') as EndDate from dbo.Resources