update a set a.P = isnull( ( select top 1 P from B b where a.I >= b.SI and a.I <= b.EI order by (b.EI-b.SI) ),'') , a.C = isnull( ( select top 1 C from B b where a.I >= b.SI and a.I <= b.EI order by (b.EI-b.SI) ),'') from A a 更新语句order by 就不要了.. B.P和B.C的默认值由NULL改成'',这样就省判断了 不用 order by 不能保证数据顺序 Null 是没有找到的时候 默认设置 数据库设计存在问题。 没办法优化了吗? sql2000 的数据库 SQL code: update A set A.P = isnull( c.P,'') , A.C = isnull( c.C,'') from B where A.I >= B.SI and A.I <= B.EI and (B.EI - B.SI) = min(B.EI - B.SI)