Insert into Table(a, c, d) select c from Table????
如果表里没有c,才插入。
请大家帮帮看看。

解决方案 »

  1.   

    update tb
    set c =t.c
    from tb1
    where tb.id=tb.id 
    and isnull(tb.c,'')=''
    --?????????
      

  2.   

    Insert into Table(a, c, d) select x,y,z from anothertable a where not exists(select 1 from Table where c=a.y)
      

  3.   

    我就是用Insert into Table(a, c, d)
    又想查找select c from Table一下表里如果没有c才做Insert into Table(a, c, d) 
      

  4.   

    c 是什么?
    如果c 是从另一个表中查得的,那见3楼.
    如果c 是一个变量值 @c,则:
    if not exists(select 1 from table where c=@c)
      insert into table(a,c,d)values(@a,@c,@d)
    注意,既然insert into table(a,c,d)了,则后面必须有三个插入值.
      

  5.   

    我就是用Insert into Table(a, c, d)
    又想查找select c from Table一下表里如果没有c才做Insert into Table(a, c, d) if not exists(select 1 from [table] where ...)
       Insert into Table(a, c, d)