I'm trying to do something like this but it doesn't work.
DECLARE @Output TABLE( OldReferenceValue INT, NewReferenceValue INT )
INSERT INTO FileManagerReferenceMessage (FileManagerFileID, ReferenceMesssage)
OUTPUT Refs.ID, inserted.ID INTO @Output(OldReferenceValue, NewReferenceValue)
SELECT ID, [Data2] AS ReferenceMessage FROM @References AS Refs WHERE ID <= 0
I am sending into s SQL Server stored procedure a table-valued parameter called @References that contains an ID for a record derived from an external system. The ID in the scenario is a negative number. I want to do a bulk insert of these records letting SQL Server IDENTITY set the local ID and correlate the inserted IDs back to the external system IDS.