update Objects set IsSource = 0 where id in (select distinct dest_id from Tasks);

go

for f as curs scroll cursor for
  select id as @id, source_id as @s_id, dest_id as @d_id from Tasks
do
  insert into SvoObjectsStn(Glava, Svoistvo, Stoinost) select @s_id, Svoistvo, Stoinost from SvoObjectsStn 
           where Svoistvo <> 25 and Glava = @d_id and Svoistvo not in 
		     (select Svoistvo from SvoObjectsStn where Glava = @s_id);
end for;

go

delete from SvoObjectsStn where Glava in (select distinct dest_id from Tasks) and Svoistvo <> 25