Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8079613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:09:45+00:00 2026-06-05T16:09:45+00:00

I have a table with columns say col1, col2, col3 . The table has

  • 0

I have a table with columns say col1, col2, col3. The table has many rows in it.

Let’s assume val1, val2, val3 is one such row. I want to get the result as

Col1, Val1
Col2, Val2
Col3, Val3

That is 3 rows – one for each column and its value.

I am using SQL Server 2008. I read about pivots. Are pivots a way to solve this problem? Can someone route me to some examples or solutions how to solve this problem?

Thanks a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:09:47+00:00Added an answer on June 5, 2026 at 4:09 pm

    Maybe something like this:

    Test data

    DECLARE @T TABLE(Col1 INT, Col2 INT, Col3 INT)
    INSERT INTO @T
    VALUES (1,1,1)
    

    Query

    SELECT
        *
    FROM
    (
        SELECT
            t.Col1,
            t.Col2,
            t.Col3
        FROM
            @T AS t
    ) AS SourceTable
    UNPIVOT
    (
        Value FOR Col IN
        (Col1,Col2,Col3)
    ) AS unpvt
    

    Output

    1   Col1
    1   Col2
    1   Col3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a table Foo . This table has the columns ID
Suppose I have a table ABC and table XYZ. Columns of ABC-->col1 col2 col3
If I have a table TABLE_1 with, lets say 5 columns: COL1 | COL2
Let's say I have table TabA with columns: col1 - primary key (but not
I have a table say table1 which has 3 columns column1, column2 and column3
Let's say I have an employee table with columns: Id, Name, Birthdate I am
I have a table with two columns, customer id and order. Let's say I
Let's say we have a table with columns DAY and NUMERO. There can be
Let's say I have a Table of rows that contain coordinates. What would be
I have table like this col1 col2 col3 3 5 8 4 5 5

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.