DE-NORMALIZING RECORDS

  • I have a table constructed as follows:

    CID CHAR(8)

    SRVDATE INT

    FLDNAME VARCHAR(10)

    FLDVAL VARCHAR(20)

    SAMPLE DATA LOOKS LIKE THIS

    CID SRVDATE FLDNAME FLDVAL

    123 20090101 MEMBERID 999888777

    123 20090101 PCODE 192.00

    123 20090101 CHKDATE 20081231

    123 20090101 CHKN0 100101

    I NEED TO TAKE THE DATA IN THIS TABLE AND TRANSFORM INTO

    INTO A SINGLE RECORD AS

    CID SRVDATE MEMBERID PCODE CHKDATE CHKNO

    123 20090101 999888777 192.00 20081231 100101

    Any TSQL ideas?

  • I don't know what is going on here, but for some reason I can't post my code directly in this thread.

    Attached is the code I put together for your problem. Please note how I packaged the table DDL and sample data. You can easily cut/paste/run the code in SSMS without having to complete any editing of the code. this is how you should post your code when asking for help. For more on this read the first article I have referenced below in my signature block regarding asking for help.

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

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