应该你说的那VAG不行,因为是求平均值的函数, 一种方法就是你上面学的, 另外一种就是 建一个视图myview,表的列包含除“instruction,sn”以外的所有列 然后 select * from myview 这是我的个人想法,如果你有更好的方法请到时候发信息给我OK??
可以实现--给你一个思路吧 --建表 create table tb(id int,name varchar(10),content int) insert into tb select 1,'lkj',2 --查询 declare @columnname varchar(100) declare @a varchar(300) set @a='' select @a=@a+','+name from syscolumns where id=object_id(N'tb') and name not in('id' ,'name') --在这里输入不想显示的字段 set @a=stuff(@a,1,1,'') exec('select '+@a+' from tb')--结果 content 2 这个东东最好做成一个存储过程
一种方法就是你上面学的,
另外一种就是 建一个视图myview,表的列包含除“instruction,sn”以外的所有列
然后 select * from myview
这是我的个人想法,如果你有更好的方法请到时候发信息给我OK??
--建表
create table tb(id int,name varchar(10),content int)
insert into tb select 1,'lkj',2
--查询
declare @columnname varchar(100)
declare @a varchar(300)
set @a=''
select @a=@a+','+name from syscolumns where id=object_id(N'tb') and name not in('id' ,'name') --在这里输入不想显示的字段
set @a=stuff(@a,1,1,'')
exec('select '+@a+' from tb')--结果
content
2
这个东东最好做成一个存储过程