建议使用unpivot
不然使用这种方式也可以
Select
id,
Case
When TID=1 Then c1
When TID=2 Then c2
When TID =3 Then c3
When TID=4 Then c4 Else Null End as newCell
From
(--这个是数据源,这里为了方便测试暂时拼接一个作为数据源
Select 1 as id, 'a' as c1,'b' as c2 ,'c' as c3,'d' as c4
Union All Select 2 as id, 'e' as c1,'f' as c2 ,'g' as c3,'h' as c4
Union All Select 3 as id, 'i' as c1,'j' as c2 ,'k' as c3,'m' as c4
) as s Left Join
--这个表是拼接起来的,拼几行要看你有几列
(Select 1 as TID Union All Select 2 Union All Select 3 Union All Select 4) as t
On 0=0