In SQL Server 2008, is it possible to insert data from a source table into a dest table and update the source table with @@identity from the dest table at the same time?
Example
Table Source:
Id - UniqueId
Name - varchar(10)
RealId [null] - int
Table Dest
Id - [id] INT identity
Name - varchar(10)
I want to transfer rows from Source into Dest, and update the RealId
to the @@identity value from the Dest table
I can modify Source in any way I like, the Dest table may not be altered.
What are my best options here?
Also note, the "Name" column may contain duplicates so I can't really join on that.
(The real tables are much more complex, but this should give and idea of what I want)