best way to Parse xml throgh t-sql

  • declare @appro_xml xml ;

    set @appro_xml='

    102021010012419

    11

    12

    14

    15

    1

    0

    1

    110

    0

    0

    Company

    168

    ghfh

    Steve

    Martin

    7

    89082

    28.50108351020

    623-17-8923

    John

    Hill

    7

    205008

    71.50108351020

    623-22-5433

    Company

    201

    sjkfhjklfhasdkfhsd

    Joseph

    Brenann

    7

    102001

    50.00918761020

    233-21-7654

    Curt

    Provenzo

    7

    102344

    50.00918761020

    623-14-2314

    Indvidual

    177

    afsjkhf

    Tim Denniston

    544-12-2354

    1

    200345

    Limited

    1611 45 St.10 Downing St.Brooklyn

    NY

    USA11204

    Jason Houseman

    761-33-3354

    1

    150000

    UnLimited

    c/o National Realty and Development Corp.3 Manhattanville RoadPurchase

    PA

    USA10577

    Michael J. Prendergast

    623-14-2987

    1

    90000

    Limited

    301 Exchange BoulevardRochester

    NY

    USA11204

    '

    select

    x.col.value('SolicitationID[1]','INT')AS request_id ,

    d.dec.value('DeclineReasonCode[1]','varchar(500)')AS DeclineReasonCode

    -- , x.col.value('DBAName[1]','VARCHAR(500)')AS DBAName

    FROM @appro_xml.nodes('//ScoreAndDataRetrievalRequest') x(col)

    CROSS APPLY col.nodes('DeclineReasonCode') d(dec)

  • First, if there's supposed to be XML in the post, you need to surround it with the correct tags, or convert the carrets to HTML codes.

    Second, did you have a question or anything like that?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I edited the code.

    If you have a question, the title / description is not the place to put it.You also need to describe what issue you are having and what goal you have. There is no "best" way.

  • Steve:

    This one's actually a pretty much duplicate post. He and Flo have been discussing the same thing, with the same problems in his posts, on another thread.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I am getting problem parsing the xml using t-sql,

    Not getting all node value...

    any idea...

  • What do you want to get? What are you trying for?

    Give some sample data, show what you want the output to be, include and error messages, etc.

  • Closing thread. Please post here: http://www.sqlservercentral.com/Forums/Topic703170-338-1.aspx

Viewing 7 posts - 1 through 6 (of 6 total)

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