t1 has an automatically generated primary key called pkId
INSERT INTO t1( title, summary)
OUTPUT inserted.pkId, t2.id INTO @IdTable(New_Id, Old_Id)
SELECT t2.title, t2.summary
FROM t2
Can someone please tell me why this doesn’t work?
I’m getting the error The multi-part identifier “t2.id” could not be bound.
From Comments
Not an elegant solution but the easiest might be to
t2IDcolumn tot1INSERTto include thet2ID(not using anOUTPUTclause)@IdTableSQL Script