在MS SQL中将行转换为单临时表中的列

问题描述:

嗨伙计们,



我希望在MS SQL的单临时表中将行转换为列。

例如,让我们说我有这张桌子。

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到13是可变的,不是固定。也可能是9到15岁。



你们对此有好主意。

谢谢xo xo。 :)



我尝试了什么:



我试过这个但是没有用。

有效地将行转换为列在sql server中 - Stack Overflow [ ^ ]