need help transforming row values to a table

  • my table select name,value from xxtable gives the result

    nodename value

    DTP02_DateTimePeriodFormatQualifier D8

    DTP03_AdjudicationorPaymentDate 20130408

    SVD_LineAdjudicationInformation NULL

    C003_CompositeMedicalProcedureIdentifier_3 NULL

    C00301_ProductorServiceIDQualifier HC

    how do i transform the result set or table columns eg. using tsql

    DTP02_DateTimePeriodFormatQualifier | DTP03_AdjudicationorPaymentDate ....... etc...

    -----------------------------------------------------------------------

    D8 20130408

  • Look up the syntax for PIVOT BY. But if those are your only two columns, it might not work directly- you may have to add a constant-valued column.

  • ron morgan (8/14/2013)


    how do i transform the result set or table columns eg. using tsql

    See the following article for two different methods. Instead of using SUM(), use MAX().

    http://www.sqlservercentral.com/articles/T-SQL/63681/

    After that and if you want to do it dynamically, see the following article...

    http://www.sqlservercentral.com/articles/Crosstab/65048/

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

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

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