如果key不需要更新的话:update table1 set a1=aa.a1,a2=aa.a2,a3=aa.a3 from table1 aa where aa.[key]=@num1 and table1.[key]=@num2
update table1 set a1=b.a1, a2=b.a2, a3=b.a3 from table1 b where b.key=num2 and table1.key=num1
update table1 set a1=b.a1, a2=b.a2, a3=b.a3 from table1 b where b.key=num2 and table1.key=num1
上面的方法我试过了,好像通不过的:(应该是这样才对呀: update Table1 set a1=b.a1,b1=b.b1,c1=b.c1,[key]=b.[key] from (select * from table2) as b where b.[key]=num2 and table2.[key]=num1
where key =num1
set a1=b.a1,
a2=b.a2,
a3=b.a3
from table1 b
where b.key=num2 and table1.key=num1
set a1=b.a1,
a2=b.a2,
a3=b.a3
from table1 b
where b.key=num2 and table1.key=num1
update Table1
set a1=b.a1,b1=b.b1,c1=b.c1,[key]=b.[key]
from (select *
from table2) as b
where b.[key]=num2 and table2.[key]=num1