What is this thing I need to do called?

  • Hi,

    I think this is pretty common, but I don't know what it's called so I can't search for it.

    I have a client who keeps records of Students in excel files. My job is to pull them out and create a SQL Server database for them. These files all have columns like ClassTaken1, ClassTaken2, ClassTaken3 etc., somtimes up to a dozen or two of them. Obviously I want to pull that data out of the flat file and create a related table for Student Enrollment.

    I thought what I was looking for was called PivotTables, but it turns out that that's kind of the opposite. Any idea what this is called? Thanks.

    Aaron

  • You're trying to UNPIVOT or re-normalize your data. The 2005 method is the UNPIVOT; past versions would require a series of SELECT statements smushed together with UNION or UNION ALL.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Heh... reminds me of a dictionary... how can you check the spelling on a word using a dictionary without a bit of luck?

    I agree with Matt... UNPIVOT is what you're most likely looking for. There's some other ways to do it, as well but, since you're using 2k5, that's as good as any a place to start.

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