declare cur cursor for select AccountID,EmployeeName from #Temp open cur fetch next from cur into @tmpID, @tmpName fetch next from cur into @tmpID, @tmpName end close cur deallocate cur