try:
select * into #tmp from 表1 where A1 = '30'update a set a.a3 = b.a3,a.a4 = b.a4,a.a5 = b.a5,a.a6 = b.a6
from 表1 a
join 表2 b on a.a1 = 30 and b.a1 = 9update a set a.a3 = b.a3,a.a4 = b.a4,a.a5 = b.a5,a.a6 = b.a6
from 表1 a
join #tmp b on a.a1 = 9 and b.a1 = 30drop table #tmp

解决方案 »

  1.   

    select a3,a4,a5,a6,identity(int,1,1) as id into #t from table1update table1 set a3=b.a3 and a4=b.a4 and a5=b.a5 and a6=b.a6
    from table1 a, #t B 
    where a.a1=30 and b.id=2update table1 set a3=b.a3 and a4=b.a4 and a5=b.a5 and a6=b.a6
    from table1 a, #t B 
    where a.a1=9 and b.id=1drop table #t
      

  2.   

    id号改一下:select a3,a4,a5,a6,identity(int,1,1) as id into #t from table1update table1 set a3=b.a3 and a4=b.a4 and a5=b.a5 and a6=b.a6
    from table1 a, #t B 
    where a.a1=30 and b.id=3update table1 set a3=b.a3 and a4=b.a4 and a5=b.a5 and a6=b.a6
    from table1 a, #t B 
    where a.a1=9 and b.id=2drop table #t