DECLARE @ID int
--定义游标
DECLARE MyCursor CURSOR
FOR SELECT ID FROM tbclass_1
--打开一个游标
OPEN MyCursor
--循环一个游标
FETCH NEXT FROM MyCursor INTO @ID
WHILE @@FETCH_STATUS =0
BEGIN
--sql代码块
FETCH NEXT FROM MyCursor INTO @ID
END
CLOSE MyCursor --关闭游标
DEALLOCATE MyCursor --释放游标