存储过程中循环的问题
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