Hi
I try to use cursor to print the data in a table.
My problem is, the last record always get printed twice.
Is this a known sybase problem? How can I fix this?
For example.
testTable
Name
---------
test1
test2
Code:
create procedure test
as
begin
declare @name char(5)
declare crsr cursor for select Name from testTable
open crsr
while (@@sqlstatus != 2)
begin
fetch crsr into @name
print 'name = %1!', @name
end
end
go
The result is
name = test1
name = test2
name = test2
How can I fix it, so it prints
name = test1
name = test2
Thanks in advance for any help in this