游标循环数据集合进行操作
代码:
--定义数据 DECLARE @id INT --定义游标 DECLARE sendCkeck_Cursor CURSOR FOR SELECT A.ID FROM dbo.OM_Request_Check A WHERE ISNULL(A.SendCheckFlag,0) = 0 AND A.Result = 'Checking' ORDER BY A.CreateDate ASC --打开游标 OPEN sendCkeck_Cursor --读取游标元素 FETCH NEXT FROM sendCkeck_Cursor INTO @id WHILE(@@FETCH_STATUS=0) BEGIN --开始循环遍历发送数据 SELECT @id --继续循环下一个数据 FETCH NEXT FROM sendCkeck_Cursor INTO @id END --关闭游标 CLOSE sendCkeck_Cursor --释放游标 DEALLOCATE sendCkeck_Cursor
参阅:https://blog.csdn.net/ClearLoveQ/article/details/83579287