sqlserver 游标使用
DECLARE cursor_name CURSOR FOR --定义游标 SELECT REPLACE(JSURL,'&FP=1&FP=1','&FP=1'),JSImgID FROM [srv_lnk_wps].wps_jt_2017.dbo.T_JSURL0331 WHERE JSImgID IS NOT NULL AND JSURL IS NOT NULL GROUP BY JSImgID,JSURL OPEN cursor_name --打开游标 declare @JSURL NVARCHAR(100), @JSImgID int FETCH NEXT FROM cursor_name INTO @JSURL,@JSImgID --抓取下一行游标数据 WHILE @@FETCH_STATUS = 0 BEGIN UPDATE [srv_lnk_wps].wps_jt_2017.dbo.T_IMAGEURL0331 SET F_ADDR_Url=@JSURL WHERE ID=@JSImgID FETCH NEXT FROM cursor_name INTO @JSURL,@JSImgID END CLOSE cursor_name --关闭游标 DEALLOCATE cursor_name --释放游标