Hi, I am trying to loop for each employee id in a table.
BEGIN declare @empId nvarchar(50) declare cur Cursor LOCAL for select EmpId from EmployeeMaster open cur fetch next from cur into @empId while @@FETCH_STATUS =0 begin select @empId end close cur END
This is my request in a stored procedure. What is wrong with that? it gives me the first employee id in an infinite loop. If I checked while @@ FETCH_STATUS = 1, I did not give a way out. just saying Command(s) completed successfully.
source share