Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

If I have data like this

"","",WAREHOUSE ID,1,2,3,4,5...
"","",WAREHOUSE CODE,BOS,HOU,LAX,NYC,CHI...
"","",WAREHOUSE NAME,BOSTON,HOUSTON,LOS ANGELES,NEW YORK CITY,CHICAGO...

But want to transform it like this

 WAREHOUSE ID, WAREHOUSE CODE, WAREHOUSE NAME
 1,BOS,BOSTON
 2,HOU,HOUSTON
 3,LAX,LOS ANGELES
 ...

If, as above, [Column 2] is the column that contains what should be the header row, and Columns 3 through 40 contain what should be row values, which columns get selected and set to pass through for the UNPIVOT to perform the desired transposition?

Or is UNPIVOT not even what I'm looking for?

share|improve this question

1 Answer 1

Yes the Unpivot Transformation should work, as long as the number of input columns does not vary.

Looking at your example, it looks like [Column 2] (e.g. WAREHOUSE ID) should be set as the Pivot Key Value. You can ignore any output columns that you dont want to output e.g. the Pivot Key Value Column Name.

share|improve this answer
1  
You should attempt to provide a solution showing that UNPIVOT works. –  Max Vernon Mar 28 '13 at 14:39
    
@Mike Honey: Unpivot does seem to be the most likely candidate, but I have not been able to find the right settings to achieve the result, could you elaborate? –  kscott Apr 2 '13 at 0:04
    
Elaborated my answer - see above. –  Mike Honey Apr 2 '13 at 4:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.