SQL Cursor 游标的使用
DECLARE @name VARCHAR(50)
--声明游标
DECLARE cursor_VAA1 CURSOR FOR SELECT VAA05 FROM VAA1
--打开游标
OPEN cursor_VAA1
--取第一条
FETCH NEXT FROM cursor_VAA1 INTO @name
--循环取所有行
WHILE(@@fetch_status=0)
BEGIN
PRINT @name
--取下一条
FETCH NEXT FROM cursor_VAA1 INTO @name
END
--关闭游标
CLOSE cursor_VAA1
--删除游标
DEALLOCATE cursor_VAA1
|