Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Annoying problem with XQuery

Author  Topic 

Zoran10
Starting Member

2 Posts

Posted - 2011-01-06 : 05:10:52
Hi,

I have following xml document:

<Root>
<Header>
<SomeTag1></SomeTag1>
<SomeTag2></SomeTag2>
</Header>
<Data>
<Item ID="1" AdditionalInfo="Some info">
<SubItem ID="1">1</SubItem>
<SubItem ID="2">2</SubItem>
<SubItem ID="3">3</SubItem>
</Item>
<Item ID="2" AdditionalInfo="Some info">
<SubItem ID="1">1</SubItem>
<SubItem ID="2">2</SubItem>
</Item>
</Data>
</Root>

I need to extra each SubItem from the xml document into the following table:

Data (
SubItemId sometype,
SubItemValue sometype,
ItemId sometype,
AdditionalInfo somety),

where 'ItemId' and 'AdditionalInfo' are parent's values and 'SubItemValue' is text value of 'SubItem' tag.

How to solve this problem in most efficent way ?

Thanks in advance,

Zoran
   

- Advertisement -