begin Declare GuestCursor Cursor For Select top 88888 XLH,SL from CP_SSQ6_005 where xtbz='0' order by XLH asc; Open GuestCursor Fetch Next From GuestCursor into @V_XLH,@V_SL; WHILE @@FETCH_STATUS = 0 Begin update CP_SSQ6_005 set xtbz='1' where xlh=@V_XLH; set @V_SL=rtrim(ltrim(@V_SL)); set @V_1=substring(@V_SL,1,2); set @V_2=substring(@V_SL,3,2); set @V_3=substring(@V_SL,5,2); set @V_4=substring(@V_SL,7,2); set @V_5=substring(@V_SL,9,2); set @V_6=substring(@V_SL,11,2); Select @V_or=dbo.F_GetOrder_2_3(@V_SL) set @T_1=CAST(@V_1 AS decimal(18,0)) set @T_2=CAST(@V_2 AS decimal(18,0)) set @T_3=CAST(@V_3 AS decimal(18,0)) set @T_4=CAST(@V_4 AS decimal(18,0)) set @T_5=CAST(@V_5 AS decimal(18,0)) set @T_6=CAST(@V_6 AS decimal(18,0)) set @T_JE=@T_1+@T_2+@T_3+@T_4+@T_5+@T_6; if(@T_JE>=121) begin update CP_SSQ6_005 set scbz='1',xtbz='1' where xlh=@V_XLH; waitfor delay '00:00:00';-- end; Fetch Next From GuestCursor into @V_XLH,@V_SL; end Close GuestCursor DealLocate GuestCursorend
?
我有一個(gè)百萬數(shù)據(jù)庫,需要循環(huán)取值進(jìn)行計(jì)算,現(xiàn)在是用游標(biāo)每次只能取88888 條記錄,這樣很麻煩,有沒有百萬數(shù)據(jù)庫循環(huán)取值進(jìn)行更新的算法
百萬數(shù)據(jù)庫循環(huán)取值進(jìn)行更新的算法
手掌心
2018-12-07 02:19:01