declare @ varchar(8000)
set @=''
select @=@+rtrim(name)+',' from syscolumns where id=object_id('你的表名') and name not in '你不要的10个字段'
set @=left(@,len(@)-1)exec('select '+@+' from 你的表名')

解决方案 »

  1.   

    declare @ varchar(8000)
    set @=''
    select @=@+rtrim(name)+',' from syscolumns where id=object_id('你的表名') and name not in ('你不要的列名1','你不要的列名2')
    set @=left(@,len(@)-1)
    exec('select '+@+' from 你的表名')
      

  2.   

    declare @ varchar(8000)
    set @=''
    select @=@+rtrim(name)+',' from syscolumns where id=object_id('你的表名') and name not in ('字段1','字段2',...'字段10')
    set @=left(@,len(@)-1)exec('select '+@+' from 你的表名')
      

  3.   

    declare @s varchar(8000)
    set @s=''
    select @s=@s+','+name from  syscolumns where object_id('要查询的表名')=id
    and name not in('要排除的字段1','要排除的字段2',...'要排除的字段10')
    set @s=substring(@s,2,8000)
    exec('select '+@s+' from 要查询的表名')
      

  4.   

    --改为下面的就行了.declare @s varchar(8000)
    set @s=''
    select @s=@s+','+name from  syscolumns where object_id('要查询的表名')=id
    and name not in('要排除的字段1','要排除的字段2',...'要排除的字段10')
    order by colid  --加上这句就行了
    set @s=substring(@s,2,8000)
    exec('select '+@s+' from 要查询的表名')