当前位置: 代码迷 >> Sql Server >> 存储过程中循环的有关问题
  详细解决方案

存储过程中循环的有关问题

热度:69   发布时间:2016-04-27 20:23:31.0
存储过程中循环的问题
CREATE   PROC   CD_Update
      @CDID   int
AS
      Select   ID   From   CDList   Where   CDID   =   @CDID
      下面要循环更新符合条件的所有记录,该怎么写?
GO

------解决方案--------------------
CREATE PROC CD_Update
@CDID int
AS
declare @id int
DECLARE Cur_test CURSOR FOR
Select ID From CDList Where CDID = @CDID
OPEN Cur_test
FETCH NEXT FROM Cur_test INTO @id
while @@fetch_status = 0
begin
............

FETCH NEXT FROM Cur_test INTO @id

end

GO
  相关解决方案