;with cte
as
(
select id, tenor, instno, emi, intrest, prin
from
(
select row_number() over (partition by id, tenor order by instno desc) as rn,*
from tabl_schedule
)t
where rn=1
)
update t
set t.emi = c.emi,
t.prin = c.prin
from tabl_schedule t
inner join cte c
on c.id = t.id
and c.tenor = t.tenor
where t.instno = 3
and c.instno > 3
delete from tabl_schedule where instno > 3
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/