SQL server游标基本结构
简单游标遍历数据:
BEGIN DECLARE QZ_cursor CURSOR SCROLL FOR SELECT NAME FROM USERINFO OPEN QZ_cursor DECLARE @v_ID VARCHAR(100) FETCH NEXT FROM QZ_cursor INTO @v_ID WHILE @@FETCH_STATUS=0 BEGIN --loop PRINT @v_ID FETCH NEXT FROM QZ_cursor INTO @v_ID END CLOSE QZ_cursor DEALLOCATE QZ_cursor END