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

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/rmak2008/archive/2008/12/16/3530623.aspx

posted on 2009-07-07 08:59  大宇MVP  阅读(200)  评论(0)    收藏  举报