troubleshooting Question

TSQL - Select columns as row values

Avatar of thinklings
thinklings asked on
Microsoft SQL ServerSQL
5 Comments3 Solutions73 ViewsLast Modified:
I have a table that looks similar to the below:

UserID         Column1    Column2   Column3
1                   10                20              30
2                   40                50              60
3                   70                80              90
4                   100              110            120

I would like to run a select query that grabs the table data in the format below:

UserID     Column         Value
1                Column1       10
1                Column2       20
1                Column3       30
2                Column1       40
2                Column2       50
2                Column3       60
3                Column1       70
3                Column2       80
3                Column3       90
4                Column1       100
4                Column2       110
4                Column3       120
ASKER CERTIFIED SOLUTION
shalini sinha

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros