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.
t2.idin yourSELECTstatement. To make it work, you should addt2.idto your statement but that would also require you toINSERTthis ID int1wich (I assume) is not what you need. I'm still pondering on how to resolve that elegantly.