Find the sample code used.
Insert will be done using If not Exist compaing Processed_data Table.
UPDATE Processed_data set
actual_amount=isnull(amount,0),
earned_amount=isnull(amount,0)
from
processed_data pro ,
employee_current emp,
salary_fixed fix,
component comp,
process_employee proemp
where
emp.employee_id = fix.employee_idand
fix.employee_id=pro.employee_idand
pro.employee_id=proemp.employee_idand
fix.component_id = comp.component_id and
comp.component_id = pro.component_idand
pro.pay_group_id=emp.pay_group_id and
emp.pay_group_id=comp.pay_group_idand
comp.pay_group_id=proemp.pay_group_idand
emp.pay_group_id = @mpaygroupidand
comp.s_calculatiotype in ('X','C','F')and
proemp.s_timestamp=@mTimestamp
-
update processed_data set
lop_amount = Case When sal.lop_days_ern>=@mstandarddays Then 0 Else
(earned_amount*12/365)*(sal.lop_days_ern-(-isnull(dojdays,0))) End,
earned_amount = Case When sal.lop_days_ern>=@mstandarddays Then 0 Else
earned_amount-((earned_amount*12/365)*(sal.lop_days_ern-(-isnull(dojdays,0)))) End
from
processed_data pro,
component_settings sett,
employee_current emp,
salary_data sal,
process_employee proemp
where
pro.employee_id=emp.employee_id and
emp.employee_id = sal.employee_id and
sal.employee_id=proemp.employee_id and
pro.component_id = sett.component_id and
pro.pay_group_id = emp.pay_group_id and
pro.d_pay_date = sal.d_pay_date and
emp.pay_group_id = @mpaygroupid and
sett.s_component_code='UNPAID_LEAVE' and
(sal.lop_days_ern>0 or isnull(sal.stddays_ern,0)<>isnull(sal.wrkdays_ern,0))and
sal.d_pay_date=@mpaydate and
proemp.s_timestamp=@mTimestamp