update A set 
    字段3=(select top 1 字段1 from 表B B order by A.字段1-B.字段1)
from 表A A

解决方案 »

  1.   

    update A set A.字段3 = A.字段1-B.字段1 from A,B where 连接条件
      

  2.   

    update m
    set 
        字段3=n.字段1
    from
        A m,B n
    where
        not exists(select 1 from B where (m.字段1-字段1)<(m.字段1-n.字段1))
      

  3.   

    谢谢各位,能用MIN()函数吗,order by 会不会太慢了表A和表B的关系是a.code=b.code 
    这样表B有N条记录,但选  MIN(表A.字段1-表B.字段1) 的那条记录赋到A.字段3