Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Help with INTO clause in FETCH

Author  Topic 

JimJudge
Starting Member

7 Posts

Posted - 2003-07-09 : 10:07:57
This is driving me crazy! I thought it worked once but I might be dillusional!

The following works fine when I remove the INTO clause in the FETCH statements. When the INTO clause is in there it fails (@@FETCH_STATUS=-1)I have checked data types 100 times, etc. etc. If anyone has any ideas on this I would be very happy man!

DECLARE @JobID int
SET @JobID = 1

--declare the cursor
DECLARE MyCursor Cursor
LOCAL
STATIC
READ_ONLY
FOR
SELECT
Page
FROM
Notification
WHERE
JobID = @JobID

DECLARE @Page bit

--create the cursor set
OPEN MyCursor

FETCH FROM MyCursor INTO @Page

--fetch each row from the cursor assigning values to variables
--then process the row information
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH FROM MyCursor INTO @Page
END

CLOSE MyCursor
DEALLOCATE MyCursor



JimJudge
Starting Member

7 Posts

Posted - 2003-07-09 : 10:14:48
Nevermind. Sorry to waste your time this is working. I'm an SQL rookie.

Go to Top of Page
   

- Advertisement -