An Alternative (Better?) Method to UNPIVOT (SQL Spackle)

  • taylor_benjamin wrote:

    I have been demonstrating how to create high performance Pivot transformations of data using SQL or Linq. Those queries both use a Pivot Table to enhance the performance of the transformation. Today I am posting the inverse, How to Achieve High Performance Un-Pivot Transformations Using a Pivot Table. You don't have to rely on your reporting engine to perform your Pivot/Un-Pivot work. You can do it in your database engine, or using Linq for non-SQL data sources. The Linq version works with sets that are IEnumerable<>. This technique is the fastest un-pivot method I have found in the last 20 years, hands down. Cheers, Ben

    Heh... so much for the "fastest method in 20 years"... Here's what I get when I click on the link or copy the underlying URL...

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

  • Damn... It's been 5 years already.  I miss you buddy!

    --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 2 posts - 46 through 46 (of 46 total)

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