select * from table,
如果我要选择的是除了一个字段以外的所有字段,怎么写?
有没有select * except A from table 类似这种写法?
最土的就是select A,B,C... from table,如果有100个字段岂不麻烦死?

解决方案 »

  1.   

    select A,B,C... from table没有别的办法
      

  2.   


    declare @fields varchar(2000)
    select @fields=isnull(@fields+',','')+name from syscolumns where id=object_id('表名') and name<>'不需要的字段'
    order by colid
    exec('select '+@fields+' from 表名')
      

  3.   


    可用
    declare @s nvarchar(4000)
    select @s=isnull(@s+',','')+quotename(Name) from syscolumns where ID=object_id('Tab') and Name='A'
    print @s
      

  4.   

    可用
    declare @s nvarchar(4000)
    select @s=isnull(@s+',','')+quotename(Name) from syscolumns where ID=object_id('Tab') and Name not in('A')--改改
    print @s--顯示字段