I created this cursor routine and I can only run it once after that my fetch status = -1 all the time here is the routine. Any ideas are welcome. Thanks. epnico.
DECLARE RP1 CURSOR
FOR
SELECT POL_NBR FROM #RPTEST
OPEN RP1
DECLARE @WSPOLNO CHAR(10)
PRINT CONVERT(CHAR,@@FETCH_STATUS)
WHILE @@FETCH_STATUS <> -1
BEGIN
PRINT 'in loop'
FETCH RP1 INTO @WSPOLNO
PRINT @WSPOLNO
END
CLOSE RP1
DEALLOCATE RP1
DECLARE RP1 CURSOR
FOR
SELECT POL_NBR FROM #RPTEST
OPEN RP1
DECLARE @WSPOLNO CHAR(10)
PRINT CONVERT(CHAR,@@FETCH_STATUS)
WHILE @@FETCH_STATUS <> -1
BEGIN
PRINT 'in loop'
FETCH RP1 INTO @WSPOLNO
PRINT @WSPOLNO
END
CLOSE RP1
DEALLOCATE RP1