select 字段列表  from tb

解决方案 »

  1.   

    declare @s varchar(100)
    select @s=coalesce(@s+',','')+name 
    from syscolumns 
    where id=object_id('jobs') and name<>'job_id'
    exec('select '+@s +' into t from jobs')select * from t别人的给你参考
      

  2.   

    select 需要的字段 from 表
    应该没有好的办法了吧!
      

  3.   

    二楼 能否解释一下
     select   @s=coalesce(@s+',','')+name   
    是什么含义,
      

  4.   


     select       @s=coalesce(@s+',','')+name       coalesce 是判断当前字符是否为null ,如果是的话值为表达式2,你把它换为isnull()也一样
      

  5.   

    你可以把语句print出来再贴到视图里面,省得自己写了.declare   @s   varchar(100)
    select   @s=coalesce(@s+',','')+name  
    from   syscolumns  
    where   id=object_id('jobs')   and   name <> 'job_id'
    print 'select   '+@s   +'  from   jobs'
      

  6.   

    declare       @s       varchar(100) 
    select       @s=coalesce(@s+',','')+name     
    from       syscolumns     
    where       id=object_id('jobs')       and   name <> ......