Click here to Skip to main content
14,358,929 members
Rate this:
Please Sign up or sign in to vote.
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.
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[^]
Updated 10-Mar-19 19:34pm
Ram Nunna 11-Mar-19 4:52am
Could you please post your query.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100