CREATE table a( id int identity(1,1), name nvarchar(50), math nvarchar(50), score nvarchar(50), ) insert into a VALUES('张三','数学','50') insert into a VALUES('李四','语文','60') select * from a SELECT name,cc ,ss from a unPIVOT(ss for cc in (math,score)) as up select * from a
cc表示的是要进行列转行的项
ss是列转行之后所对应的值
可以看下图做了解