ALTER TRIGGER [dbo].[salefpclear] ON [dbo].[ICTSale]
AFTER DELETE
AS
BEGIN
SET NOCOUNT ON;
DECLARE @fid int
declare tab cursor for select fid from deleted
open tab
fetch next from tab into @fid
while @@FETCH_STATUS=0
update icsaleentry set FEntrySelfI0567=0,FEntrySelfI0468=0
from icsaleentry t1
inner join [dbo].[ICTSaleEntry] t2 on t1.FInterID=t2.fid_src and t1.FEntryID=t2.FEntryID_Src and t1.FItemID=t2.FItemID
where t2.fid=@fid
FETCH NEXT FROM tab into @fid
end
close tab
deallocate tab