Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Non unique id xml node -flatten and import in to sql


Non unique id xml node -flatten and import in to sql

Author
Message
ganesh.sundara
ganesh.sundara
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 26
Hi i need to import the xml in to sql. there is no item or value in invoice node its under invoice header node. please help me to import this in to sql
i want to store each invoce and its item details in sql tables

<invoicetransmission>
<invoicetransmissionheader>
<invoiveid>333</invoiceid>
</invoicetransmissionheader>
<invoice>
<invoiceheader>
<invoicenumber>33</invoicenumber>
<items>
<itemid>44</itemid>
</items>
<invoice>
<invoice>
<invoiceheader>
<invoicenumber>323</invoicenumber>
<items>
<itemid>424</itemid>
</items>
<invoice>
</invoicetransmission>
Arthur Olcot
Arthur Olcot
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3078 Visits: 1777
To shred the xml to flat tables, you will need to use some of the xml data type methods and maybe a little bit of XQuery. the nodes() method will help you shred the xml into a relational format. the value() method will also help you extract data as well.

Here are some links to get you started.

http://msdn.microsoft.com/en-us/library/ms188282.aspx
http://msdn.microsoft.com/en-us/library/ms178030.aspx

http://msdn.microsoft.com/en-us/library/ms189075.aspx

However, have you posted live data in your example? it does look surprisingly realistic? and the addresses in the xml seem to be genuine for customers in the xml.. I hope I'm wrong and that the data is just test data and I wish that I had such good quality test data to work with :-D
Dave Convery
Dave Convery
SSC Veteran
SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)SSC Veteran (200 reputation)

Group: Administrators
Points: 200 Visits: 3536
Have you obfuscated your data in your post so you're not revealing anything you shouldn't be? This looks like an actual invoice.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search