有一个表结构如下:
表名:biao
a b c d e
请问用什么语句,只读b,c,d,e四个字段把字段A排除
除了用select b,c,d,e from biao

解决方案 »

  1.   

    动态SQL 怎么用呢?什么是动态 SQL?
      

  2.   

    --动态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