表a有列 a1,a2,a3,a4……
现在想查询出除了a1列外其他所有列,除了这样写
select a2,a3,a4.... from a
之外还有其他更简便写法吗?

解决方案 »

  1.   

    用动态:
    declare @sql varchar(4000)
    select @sql=isnull(@sql,'')+',['+name+']' from syscolumns where id=object_id('表名') and name!='a1'
    set @sql=left(@sql,len(@sql)-1)
    exec('select '+@sql+' from 表名')
      

  2.   

    别的办法~~有是有~~~~但你是为了简便~~~而不是为了解脱问题~~~所以.......
    提示:
    select name from syscolumns where id=object_id('表名')