Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi folks,

I want o convert rows to column in single temp table in MS SQL.
eg, Let's say i have this table.
TYPE	  DESC
9	  This is description 9
10	  This is description 10
11	  This is description 11
12	  This is description 12
13	  This is description 13

And i want to get it like this;
ID        TYPE_ID1    TYPE_ID2    TYPE_ID3     TYPE_ID4     TYPE_ID5
1	   9          10          11           12           13  


TYPE 9 to 13 is variable, not fixed. It could be 9 to 15 as well.

You guys have good idea for this.
Thank you xo xo much. :)

What I have tried:

I tried this but not works.
Efficiently convert rows to columns in sql server - Stack Overflow[^]
Posted
Updated 10-Mar-19 18:34pm
Comments
Ram Nunna 11-Mar-19 4:52am    
Could you please post your query.

1 solution

 
Share this answer
 
Comments
octavia81 11-Mar-19 2:13am    
Thanks but i don't want to use that (both pivot & unpivot)
MadMyche 11-Mar-19 8:00am    
Converting rows into columns is the definition of PIVOT

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900