Ok ... using what you have so far just move the select showing the new details inside the loop
while @@FETCH_STATUS=0
begin
set @hradetails=@basicsalary*23/100
set @totaldetails=@basicsalary + @hradetails
select @empname as EmpName,@emplocation as EmpLocation,@deptname as Dept ,@basicsalary as BasicSalary,@hradetails as HRA,@totaldetails as Total
fetch next from cur_sample4 into @empname,@emplocation,@deptname,@basicsalary,@hradetails,@totaldetails
end
Note that it is before the
fetch next
to ensure we don't mess up @@FETCH_STATUS
Also note that if I was doing this I would have BasicSalary, HraDetails and TotalSalary declared as
numeric
and would get the results like this ...
update #Employee_Details set HraDetails = BasicSalary * 23.0 / 100.0, TotalSalary = BasicSalary + (BasicSalary * 23.0 / 100.0)
select * from #Employee_Details