create table T
(
id int,
A varchar(10),
B varchar(10),
C varchar(10),
D varchar(10)
)
insert into T values(1 , 'A' , 'B' , 'C' ,'D')
insert into T values(2, 'E' , 'F' , 'H' , 'G')
--行变列,返过来就是列变行
select id,X from T
unpivot
(
x
for
y in([A],[B],[C],[D])
)p