0

How to convert columns to rows in SQL Server?

For example I have table with 31 columns as numbers from 1 to 31.

PFA screenshot for the same.

These no should range from 1 to 31 in row format.

2

1 Answer 1

1

You are trying to unpivot, you can use T-SQL UNPIVOT covered here: https://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx

Or, "An Alternative (Better?) Method to UNPIVOT (SQL Spackle)" by Dwain Camps found here: http://www.sqlservercentral.com/articles/CROSS+APPLY+VALUES+UNPIVOT/91234/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.