select bh=identity(int,2,2),* into #tmp from table1
update b set b.xm=a.xm,b.sex=a.sex from #tmp1 a,table2 b where b.bh=a.bh

解决方案 »

  1.   

    表table2中的2,4,6都是我从table1中放进去的
      

  2.   

    select * into #a from table1while exists (select * from #a)
        and exists ( select * from table2 where xm is null)
    begin
      update table2
       set xm=t.xm,sex=t.sex
       from (select top 1 * from #a) as t,table2 
       where table2.bh=(
        select min(bh) frim table2 where xm is null)
      set rowcount 1
      delete #a
      set rowcount 0
    enddrop table #a