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

  • 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>

  • 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 😀

  • Have you obfuscated your data in your post so you're not revealing anything you shouldn't be? This looks like an actual invoice.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply