create table 表a(typeid int,bianhao varchar(10),mingcheng varchar(10),pinzhong varchar(10),jiage varchar(10))
insert into 表a select 1,'编号','名称','品种','价格'
insert into 表a select 2,'标号','品名','规格','售价'
insert into 表a select 3,'true','true','true','true'
declare @s varchar(8000)
set @s = ''
select
@s=@s+' union select 原始名称 =max(case typeid when 1 then '+name+' end)'
+',自定义名称=max(case typeid when 2 then '+name+' end)'
+',是否显示 =max(case typeid when 3 then '+name+' end)'
+' from 表a'
from syscolumns
where id=object_id('表a') and name != 'typeid' order by colid
set @s = stuff(@s,1,6,'')
exec(@s)
drop table 表a
/*
原始名称 自定义名称 是否显示
编号 标号 true
名称 品名 true
品种 规格 true
价格 售价 true
*/
说明:
/*select name(字段名) from syscolumns where id=object_id('表a') */
insert into 表a select 1,'编号','名称','品种','价格'
insert into 表a select 2,'标号','品名','规格','售价'
insert into 表a select 3,'true','true','true','true'
declare @s varchar(8000)
set @s = ''
select
@s=@s+' union select 原始名称 =max(case typeid when 1 then '+name+' end)'
+',自定义名称=max(case typeid when 2 then '+name+' end)'
+',是否显示 =max(case typeid when 3 then '+name+' end)'
+' from 表a'
from syscolumns
where id=object_id('表a') and name != 'typeid' order by colid
set @s = stuff(@s,1,6,'')
exec(@s)
drop table 表a
/*
原始名称 自定义名称 是否显示
编号 标号 true
名称 品名 true
品种 规格 true
价格 售价 true
*/
说明:
/*select name(字段名) from syscolumns where id=object_id('表a') */