现在的位置: 首页 > 综合 > 正文

行列转换的问题

2013年07月11日 ⁄ 综合 ⁄ 共 281字 ⁄ 字号 评论关闭
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

【上篇】
【下篇】

抱歉!评论已关闭.