use jinzhong_YiZhongREN SELECT * FROM TMemberCardAccount SELECT TOP 1*INTO #Acct FROM TMemberCardAcctHist WHERE FAcctId = 5111566109868661209 SELECT * FROM #Acct SELECT * FROM TPayAccount WHERE FId = 5111566109868661209 INSERT INTO TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo) SELECT dbo.FNNeWiD(),A.FMemId,A.FCardId,A.FAcctId,GETDATE(),B.FTypeId,B.FCompId,'QD','ClearBalance',0,'',0,A.FBalance,0,0,getdate(),'²¨×ÜÈÃÇå¿Õ' FROM TMemberCardAccount AS A,TMemberCARD AS B WHERE A.FCardId = B.FCardId AND A.FAcctId = 5111566109868661209 SELECT * FROM TMemberCardAcctHist WHERE FAcctId = 5111566109868661209 UPDATE TMemberCardAccount SET FBalance = 0 WHERE FAcctId = 5111566109868661209