UPDATE A SET A.FCardId = B.FCardId FROM TMemberArrear AS A,TBKMember# AS B WHERE A.FMemId = B.FMemId AND A.FBillType ='DR_KK' AND A.FCardId = 0 UPDATE A SET A.FArrearCardId = B.FCardId FROM TMemberSaleRepay AS A,TMemberArrear AS B WHERE A.FArrearId = B.FId AND b.FBillType ='DR_KK' AND A.FArrearCardId = 0