troubleshooting Question

Pivot Only 2 Columns of Data

Avatar of KANEDA 0149
KANEDA 0149Flag for United States of America asked on
Microsoft SQL ServerSQL
3 Comments2 Solutions91 ViewsLast Modified:
I'm trying to pivot a single table that contains 7 columns but I really only need 2 of them.  One column is called ID and the other is PROFILE_ID which is the one I want to transpose/pivot into 7 new columns based on the values originally returned.   I know I can use a union but I'm trying to simply it if when I have other scenarios similar to this that have more values like 27 that needs to get transposed/pivoted.  I tried a pivot syntax but it didn't seem to work for me or at least I'm doing it wrong.  I only need the 'ID' and 'PROFILE_ID' column from the original table that needs to be pivoted or transposed.  Below is an example of the original output and what I need or expect to get.  Thanks in advance!

Original Output from select * dbo.Table
Original Output
Need Output in this Format
Expected Output
Brian Crowe
Database Manager

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

Top Expert 2005

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 2 Answers and 3 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 2 Answers and 3 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