行列转换的问题

create table tb(材料费用 int,人工费用 int,机械费用 int,其他费用 int)
insert into tb select 150,260,330,400
go

declare @sql varchar(8000)
set @sql=''
select @sql=@sql+' union all select '''+name+''' as 费用类型,'+name+' as 数目 from tb ' from syscolumns where id=object_id('tb') order by colid
set @sql=stuff(@sql,1,11,'')
exec(@sql)
drop table tb
posted @ 2006-10-14 15:48  tohen  阅读(326)  评论(0编辑  收藏  举报