Reputation: 1
I am using cursor to pass the each employee wise information to do some calculation inside,
I have used some temp table with the declaration like
declare @tempTask1 table(emplid nvarchar(10), Values bigint)
and storing it into the main table
insert into Maintable
Select * from @tempTask1
but what happens is when the loop goes the emplid
is kept on adding into the @tempTask1
.
like example
E1 1001
E2 1002
...
as per the no of times the loop goes
so duplicate entry exists for each record and calculation failed.
How to drop this temp table and recreate the emp table used inside the loop to avoid these data problems.
Note: each loop shld take only unique emplid one time when it loops
Upvotes: 0
Views: 2049