How do I rotate a table? (not Pivot)

  • I have a 1 row table that looks like this:

    FirstName MiddleName LastName

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

    Robert Ewing Jones

    I want to rotate it so it looks like this where the column headers become the values in the left column

    Name Value

    ----- ------

    FirstName Robert

    MiddleName Ewing

    LastName Jones

    if it helps, I'm doing this so I can present some data in a more logical fashion in SSRS.

    Thanks,

    Chris

  • Look up the UNPIVOT command in books online. I think it should do exactly what you're after.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I had to look at it and walk away 3 times before I finally got it, but that was exactly what I needed!

    Thank you,

    Chris

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

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