Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xquery and untyped XML datatype

Status
Not open for further replies.

hmckillop

Programmer
Oct 30, 2001
1,540
GB
I have an untyped xml data store containing an xml similiar to
Code:
<roottype xmlns="[URL unfurl="true"]http://www.namspace.com/XMLSchema/ns/DataSynchronisation"[/URL] SchemaVersion="2.1">
  <Field1>HCSK</Field1>
  <Field2>K111111</Field2>
  <Field3>2009-01-09-10.51.50.627620</Field3>
  <New>
    <Timestamp>2009-01-05-00.00.00.000000</Timestamp>
    <HouseNumber>342</HouseNumber>
    <Postcode>AA1 1AJ</Postcode>
    <RegTimestamp>2009-01-09-00.00.00.000000</RegTimestamp>
    <StreetName>Church Street</StreetName>
    <TownName>Everywhere</TownName>
    <PropName>XXX</PropName>
  </New>
</roottype>

I am trying to write a query to access the different parts of data.

I thought this should access some of the data it but it doesnt.
Code:
SELECT XMLFieldWhereXMLUntypedStored.query('/DataSynchronisation')   
FROM   MyTable

Any help in accessing any of the data e.g. field1 or townname this would be greatly appreciated.


"I'm living so far beyond my income that we may almost be said to be living apart
 
Found what I needed -
Code:
SELECT XMLFieldWhereXMLUntypedStored.value('/DataSynchronisation[1]/Field1[1]', nvarchar(10))   
FROM   MyTable

Thanks

"I'm living so far beyond my income that we may almost be said to be living apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top