XQUERY big problem

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hello
I try import data from XML file to MSSQL2005 using XQUERY
xml like:

<start>
<section>
<data1> </data1>
<data2> </data2>
<data3> </data3>
<person> P1 </person>
<person> P2 </person>
<car>
<car_name>CC1 </car_name>
</car>
</section>
<section>
<data1> </data1>
<data2> </data2>
<data3> </data3>
<person> P1 </person>
<car>
<car_name>C1 </car_name>
</car>
<car>
<car_name>C2 </car_name>
</car>
<car>
<car_name>C3 </car_name>
</car>
</section>
....
</start>

As you see data1,data2,data3 is in each <section> (i do not know how many
in each xml will be <sections>) but tag <person> or <car> can be one or
more I do not know how many the same <car> can be on or more or can not be
anything.
So I think i must prepare 3 tables, one for data1-3 one for persons and
one for cars
but how can i know that this car is from exactly this <section> and
person isfrom this section?

I can import this file into:
DECLARE @xVar XML
insert into tab_data
SELECT
tab.col.value('data1[1]', 'nvarchar(30)') As data1,
tab.col.value('data2[1]', 'nvarchar(30)') As data2,
tab.col.value('data3[1]', 'nvarchar(30)') As data3
from @xVar.nodes('//START//SECTION') tab(col)

insert into tab_cars
SELECT
tab.col.value('car_name[1]', 'nvarchar(30)') As car_name
from @xVar.nodes('//START//SECTION//car') tab(col)

insert into tab_persons
SELECT
tab.col.value('person[1]', 'nvarchar(30)') As person
from @xVar.nodes('//START//SECTION') tab(col)

and now how connect tables tab_cars, tab_persons and tab_data
How to know that car CC1 own person PP1 and PP2 and so one.

How to import this data using XQuery? And make connection between tables.

Best Regards
AJA



.



Relevant Pages

  • Is this impossible via XSL?
    ... Given this XML segment - Note it is a representation of concept of the ... Per each attribute VIN, I need to obtain the carSpecifics ... I can get CarMake ...
    (comp.text.xml)
  • Re: AxShDocVw.AxWebBrowser.Navigate and object headers
    ... Well, XML or JSON would be the obvious contenders, so (using XML for ... public Car DoSomething{ ... There are lots of ways of implementing a web-service; ... and interpret the server's response in the same manner ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: XQUERY big problem
    ... I got this XML to load into MSSQL 2005. ... able to tell which car or which person came from which section? ... I try import data from XML file to MSSQL2005 using XQUERY ...
    (microsoft.public.sqlserver.xml)
  • Re: XQUERY big problem
    ... I got this XML to load into MSSQL 2005. ... Yeah, here's your proposition: ...
    (microsoft.public.sqlserver.xml)
  • Re: galaxy quest
    ... I think that is a pretty fundamental question but consider this XML: ... it certainly doesn't make sense that one particular car would have more ... > could you please give me an example or two why you would want to specify ...
    (microsoft.public.dotnet.languages.vb)