Storing XML data

  • I have a XML date in this format:

    <? xml version="1.0" encoding="UTF-8"?>

    <ns0:GVRedReq xmlns:xsi='http://www.w3.org/2001 /XMLSchema-instance'

    xmlns:ns0='http://fks.com/gv/redemption'

    xsi :schemaLocation='http://fks.com/gv/redemption GVRedReq.xsd'>

    <ns0:StrCode>1234</ns0:StrCode>

    <ns0:TrmnlId>02</ns0:TrmnlId>

    <ns0:TrnsNo>0123456789<ns0:TrnsNo>

    <ns0:Date>03-05-2013</ns0: Date>

    <ns0:Time>11:30</ns0:Time>

    <ns0:GVDtls>

    <ns0:GVNo> VVD0000021</ns0:GVNo>

    <ns0:GVNo> VVD0000022</ns0:GVNo>

    <ns0:GVNo> BVD0003213</ns0:GVNo>

    </ns0:GVDtls>

    </ns0:GVRedReq>

    I want to store it in my database table. Its structure is like below:

    Create table GV_redeemRequest

    (

    RedeemRequestID int Primary key identity(1,1)

    StoreCode char(4),

    TerminalID int,

    TransactionNO int,

    Date date,

    Time char(5),

    GVDetails varchar(max)

    )

    How to achieve this?

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • I learn it from the article: 🙂

    http://qa.sqlservercentral.com/articles/XML/71659/

    If someone else also want to learn this then please refer this link.

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • The easiest way is to use OpenXML then you can basically use select statements against the XML table.

    Read up on OpenXML in BOL you should be able to figure it out.

    The probability of survival is inversely proportional to the angle of arrival.

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

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