Pivot Query - Columns to Rows / Column ordering

  • I have a huge table where there are close to 100 columns in the table.  If I am writing a SQL statement in the query analyzer to return one row from that table, is there anyway to pivot the query so that the result is shown as rows and not columns, i.e.

    rather than:

    Col1 Col2 Col3 ....

    I get:

    Col1

    Col2

    Col3

    ...

     

    Moreover, what will be the fastest way to get the result set ordered by column name?

  • Lots of great scripts and resources are available right here on this site.  see

    http://www.sqlservercentral.com/scripts/scriptdetails.asp?scriptid=594

    for a good pivot table proc.  There have also been a number of discussion on pivot tables in the formus.  Some of the may also help.  Just do a seach on 'Pivot table'

    Francis

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

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