create table TestKPI
(
id int,
types int,
kpi1 int,
kpi2 int
)
insert into TestKPI values(1,1,1,1)
insert into TestKPI values(12,2,13,2)
insert into TestKPI values(60,3,12,13)
insert into TestKPI values(80,4,13,1)
select * from TestKPI
select id,types,kpiname,kpivalue
from
(select id,types,kpi1,kpi2 from TestKPI)p
unpivot
(kpivalue for kpiname in
(kpi1,kpi2)
)
as unpvt
go