表A 有两个字段  key 和 value 
表B 有三个字段  title 和 value  和ord要把表B中,  如果title 包含A里的key, 那么B.value = A.value. 但是只更新B中按ord倒序的前20个
求解

解决方案 »

  1.   

    update b set value=a.value from 表A a inner join 表B b on CHARINDEX(a.[key],b.title)>0
    where b.ord in(select top 20 ord from 表B order by ord desc)
      

  2.   

    update
      b
    set
      value=a.value
    from
      a ,
      (select top 20 * from b order by ord desc)b
    where
       charindex(a.key,b.title)>0
      

  3.   

    多谢 fredrickhu  
    继续试
      

  4.   

    try:
    update b set value=a.value from 表A a inner join 表B b on CHARINDEX(a.[key],b.title)>0
    where b.ord in(select top 20 b.ord from 表A a inner join 表B b on CHARINDEX(a.[key],b.title)>0 order by b.ord desc)