I have a query which do UPSERT or update if exists and insert if not:
update MyTable set [Name]=@NewValue where ID=@ID If @@RowCount = 0 insert into MyTa
@@ROWCOUNT is tied to the scope of your current execution and is therefore unaffected by a trigger, which would run in a different scope.
@@ROWCOUNT