SQL Server 2005 +
I have a view with an INSTEAD OF INSERT trigger. Inside the body of the trigger, I want to use an operator with an OUTPUT clause that references both INSERTED tables:
- external
INSERTED table for INSTEAD OF INSERT trigger INSERTED internal table for OUTPUT clause
MSDN says this :
If the statement containing the OUTPUT clause is used inside the trigger body, tables are inserted and deleted to reference the trigger to avoid duplicate column references with the INSERTED and DELETED tables associated with the OUTPUT.
But anti-aliasing does not work:
CREATE TRIGGER v_insert ON v INSTEAD OF INSERT AS BEGIN INSERT INTO t (a, b, c) OUTPUT inserted.a, inserted.b, outer_inserted.d INTO t_prime (a, b, d) SELECT a, b, c FROM inserted as outer_inserted END
It throws the error “Unable to associate an identifier with several parts of 'external_inserted.d.' Does this mean that what I'm trying to do is impossible?
source share