--动态SQL create table tb(a int,b int,c int,d int,e int) insert into tb select 1,2,3,4,5 godeclare @sql varchar(8000) set @sql='select ' select @sql=@sql+','+name from syscolumns where id=object_id('tb') and name not in('a') order by colid --这里写不想要得列名 set @sql=stuff(@sql,8,1,'') exec(@sql+' from tb')drop table tb
create table tb(a int,b int,c int,d int,e int)
insert into tb select 1,2,3,4,5
godeclare @sql varchar(8000)
set @sql='select '
select @sql=@sql+','+name from syscolumns where id=object_id('tb') and name not in('a') order by colid --这里写不想要得列名
set @sql=stuff(@sql,8,1,'')
exec(@sql+' from tb')drop table tb