--查询数据 select Invest.UserId, BorrowReturn.RealReturnTime, Borrow.InvestType, case Borrow.InvestType when 0 then '成功000,请注意查收' when 1 then '成功111,请注意查收' when 2 then '成功222,请注意查收' when 4 then '成功444,请注意查收' else '' end as SiteMessageContent , (BorrowReturnDetail.CaptionMoney+BorrowReturnDetail.InterestMoney+BorrowReturnDetail.SubsidyInterest-BorrowReturnDetail.ReduceManageFee) as BorrowReturnMoney into #t --放入临时表中 from BorrowReturn left join BorrowReturnDetail on BorrowReturn.Id=BorrowReturnDetail.BorrowReturnId left join Borrow on Borrow.Id=BorrowReturn.BorrowId left join Invest on Invest.Id=BorrowReturnDetail.InvestId where BorrowReturn.IsDeleted=0 and BorrowReturn.IsSuccess=1 and BorrowReturnDetail.IsDeleted=0 declare @UserId int --临时变量,用来保存游标值 declare @Site
SQL 利用游标循环添加数据
最新推荐文章于 2022-06-01 14:49:38 发布