I have a situation where I need to insert multiple records/batch insert into a view which has instead of trigger. How can I retrieve the inserted identity values? I tried using the OUTPUT clause to retrieve the Id from the Inserted table but it always returns null.
Share
Using this setup.
The statement
Will give you an error.
Using an INTO clause with the insert instead.
Gives you
0as a value notnull.You can put the output clause in the trigger.
And the output will be generated for you when you do the insert.
Result:
Update:
To capture the output from the insert statement you can use
insert into ... exec (...)