Turn Column into Rows

  • Hello, I am looking to take 1 column and take that data and turn it into a row. Basically, I want to take a range of dates and make the columns.

    Here is my same code:

    CREATE TABLE #Dt_Range (DtCols varchar(12))

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/01/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/02/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/03/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/04/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/05/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/06/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/07/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/08/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/09/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/10/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/11/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/12/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/13/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/14/2016')

    INSERT INTO #Dt_Range (DTCols) VALUES ('11/15/2016')

    SELECT * FROM #Dt_Range -- This will produce a column of all the dates I want to turn into rows

    The expected result would be the following columns:

    11/01/2016 11/02/2016 11/03/2016 11/04/2016 11/05/2016 11/06/2016 11/07/2016 11/08/2016 11/09/2016 ...

  • Well, you can't turn columns into rows from that... there's nothing to pivot on.

    You might want to read this article[/url].

  • thank you very much! article solved the problem.

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

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