DELETE TMemberArrearEmployee INSERT TMemberArrearEmployee(FId,FMemId,FArrearId,FWorkType,FEmpId,FShareRate) SELECT dbo.FNGetNewId(),A.FMemId,A.FId,B.FWorkType,B.FEmpId,B.FShareRate FROM TMemberArrear AS A,TConsumeGoodsEmployee AS B WHERE A.FBizType = 'Goods' AND A.FTransId = B.FBillId INSERT TMemberArrearEmployee(FId,FMemId,FArrearId,FWorkType,FEmpId,FShareRate) SELECT dbo.FNGetNewId(),A.FMemId,A.FId,B.FWorkType,B.FEmpId,1 FROM TMemberArrear AS A,TConsumeItemEmployee AS B WHERE A.FBizType = 'Item' AND A.FTransId = B.FBillId INSERT TMemberArrearEmployee(FId,FMemId,FArrearId,FWorkType,FEmpId,FShareRate) SELECT dbo.FNGetNewId(),A.FMemId,A.FId,B.FWorkType,B.FEmpId,B.FShareRate FROM TMemberArrear AS A,TMemberSaleEmployee AS B WHERE A.FBillType = 'KK' AND A.FTransId = B.FBillId --»¹¿î INSERT TMemberSaleEmployee( FId , FBillId ,FDetailId, FWorkType , FDeptId,FEmpId ,FShareRate, FPerf ,FComm) SELECT dbo.FNGetNewId(), A.FBillId,A.FId,B.FWorkType,0,B.FEmpId,B.FShareRate,0,0 FROM TMemberSaleRepay AS A,TMemberArrearEmployee AS B WHERE A.FArrearId = B.FArrearId