insert into 表2(B,C)
select B,C
from 表1
where C = 1

解决方案 »

  1.   

    insert into 表2(B,C) 
    select B,C 
    from 表1 
    where C = 1 
      

  2.   

    insert into 表2(B,C) 
    select B,C from 表1 where C = 1
      

  3.   

    select 1.b,1.c into 2(b,c)
    where 1.c=1
      

  4.   

    还有个问题是

    insert into 表2(B,C) 
    select B,C 
    from 表1 
    where C = 1的时候表2.D要= 当前insert 表2.A的ID这个如何实现?可以用 insert into 表2(B,C,D=SELECT @@IDENTITY)    ///?????
    select B,C,
    from 表1 
    where C = 1
      

  5.   


    insert into 表2(A,B,C) select A,B,C from 表1 where c = 1
      

  6.   

    表2.D要= 当前插入行 insert 表2.A表2.A是ID
      

  7.   

    是的
    insert into 表2(B,C,D=SELECT @@IDENTITY)   
    select B,C, 
    from 表1  
    where C = 1 
    这么是可以的?
      

  8.   

    如果要ID相同,就不是插入,而是更新了,可以用下面的语句Update 表2 set 表2.B=a.B,表2.C=a.C
    from(select B,C,D 
    from 表1) a
    where a.D=表2.A and a.C = 1
      

  9.   

    insert into 表2 (B,C) select B,C from 表1 where C = 1