How to get Identity of new records INSERTED into table with INSTEAD OF trigger
问题 I am using an INSTEAD OF insert trigger on a table to set an incrementing version number on the row and also copy the row to a 2nd history/audit table. The rows are inserted to both tables without a problem. However, I am having trouble returning the new identity from the 1st table back to the user. Schema CREATE TABLE Table1 ( id INT IDENTITY(1,1) PRIMARY KEY, name VARCHAR(250) NOT NULL UNIQUE, rowVersion INT NOT NULL ) CREATE TABLE Table1History ( id INT NOT NULL, name VARCHAR(250) NOT NULL