I have INSTEAD OF TRIGGER when insert into table. The reason is that I have to get the value for some columns from other tables, before insert (or i will have to update after insert)
example:
If EXISTS(SELECT * from dbo.someOtherTable t INNER JOIN inserted i ON t.id=i.id)
SET @col2=1
ELSE
SET @col2=0
and so on....
At the end i execute insert. It works.
But then I have problems with MERGE statements, where I have update beside insert:
The target 'dbo.myTable' of the MERGE statement has an INSTEAD OF trigger on some, but not all, of the actions specified in the MERGE statement
I can replace instead of trigger to normal trigger, but then I will have to update the row after insert was done.
I can also separate Merge to update and insert statement separately.
Enable trigger also for update, but since i don't need it at update it has no sense.
Any other solution?
br, Simon