SET NOCOUNT ON;
DECLARE @ssn char(9)
DECLARE @Code char(3)
DECLARE @DateEntered char(9)
Hello, I have a simple table with three columns. The table only has like 6 records in it at this time. All I want to do is to read the contents of the table into a cursor, and then dump out the data. I am running the below script from query analyzer, but it appears to be stuck in an infinite loop. Can someone look at my cursor code, and tell me if it is broken?
PRINT '-------- Report --------';
DECLARE people_cursor CURSOR FOR
SELECT SSN, Code,DateEntered
FROM People
ORDER BY DateEntered;
OPEN people_cursor
FETCH NEXT FROM people_cursor
INTO @ssn, @Code, @DateEntered
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @ssn
PRINT @Code
PRINT @DateEntered
CLOSE people_cursor
DEALLOCATE people_cursor
END
I am just now learning about cursors.