insert into 表2(B,C) select B,C from 表1 where C = 1
insert into 表2(B,C) select B,C from 表1 where C = 1
select 1.b,1.c into 2(b,c) where 1.c=1
还有个问题是 在 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
insert into 表2(A,B,C) select A,B,C from 表1 where c = 1
表2.D要= 当前插入行 insert 表2.A表2.A是ID
是的 insert into 表2(B,C,D=SELECT @@IDENTITY) select B,C, from 表1 where C = 1 这么是可以的?
如果要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
insert into 表2 (B,C) select B,C from 表1 where C = 1
select B,C
from 表1
where C = 1
select B,C from 表1 where C = 1
where 1.c=1
在
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
insert into 表2(A,B,C) select A,B,C from 表1 where c = 1
insert into 表2(B,C,D=SELECT @@IDENTITY)
select B,C,
from 表1
where C = 1
这么是可以的?
from(select B,C,D
from 表1) a
where a.D=表2.A and a.C = 1