As the error says, you cannot change the inserted. The Calcul table will already contain the rows represented by the insert at the time the trigger is called; therefore, you are directly working with this data. Since it is possible to insert several lines at the same time, you should not work with local variables, but work with a set:
create trigger TCalcul
on dbo.Calcul
after insert
as
begin
set nocount on
update Calcul
set Resultat = case Calcul.Op
when '+' then Calcul.Num1 + Calcul.Num2
when '-' then Calcul.Num1 - Calcul.Num2
when '*' then Calcul.Num1 * Calcul.Num2
when '/' then Calcul.Num1 / Calcul.Num2
else null end
from Calcul inner join Inserted on Calcul.ID = Inserted.ID
end
go
If you cannot use the set for any reason, you should use the cursor to jump through the inserted lines.
. , Calcul ID; .
EDIT:
SET NOCOUNT ON Sql Server , , . , , (, , ). , .