• RyanRandall (5/22/2008)


    Another XML-style approach...

    drop table #Results

    ; with a as (select RowNum, cast('<parm '+ replace(replace(Parameters,'=','="'),'&','" ')+ '"/>' as xml) as Xml from #SourceTable)

    select RowNum,

    Xml.value('(parm[1]/@Subject)[1]', 'varchar(255)') as Subject,

    Xml.value('(parm[1]/@Category)[1]', 'varchar(255)') as Category,

    Xml.value('(parm[1]/@Status)[1]', 'varchar(255)') as Status,

    Xml.value('(parm[1]/@IPPDM_Count)[1]', 'varchar(255)') as IPPDM_Count,

    Xml.value('(parm[1]/@Well_Count)[1]', 'varchar(255)') as Well_Count

    into #Results

    from a

    This seems to run much faster for me, but perhaps I'm misunderstanding the problem?

    Nice... I'll throw that into a million row test and check. Thanks, Ryan.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)