When I run this code the first time in the SQL Server Management Studio it returns the results I expect but if I run it a second time I do not get any results back.
I am trying to learn about cursors and as you can see I need some help.
declare @usrName as varchar(15)
declare @FirstName as varchar(15)
declare db_cursor2 CURSOR FOR
select usr_usrnm, usr_nm_frst_txt FROM usr;
open db_cursor2
--fetch next from db_cursor
while @@FETCH_STATUS = 0
begin
fetch next from db_cursor2
end
close db_cursor2;
deallocate db_cursor2;