Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
michael.appleton
Posting Yak Master
160 Posts |
Posted - 2008-12-23 : 07:48:54
|
Hello,Rather simple question I believe. I am importing data from an old database that is still used but also have other data sources so the surrogate ids in this old database are not used in the main database. Basically it's a legacy database that we are trying to phase out.The problem is I want to insert new rows into the main database and on the insert I would like to retrieve the newly created ids and the corresponding oldids as an output to store in another table. The query is below: DECLARE @Ids Table( Id int Primary Key, OldId int Unique )INSERT INTO Seeds(EntryDate) OUTPUT INSERTED.Id, D.OldId --this is not allowed INTO @Ids SELECT D.[Entry Date] FROM Data D I've high lighted the part of the code that doesn't work. Does anyone know how to do this? Thanks,Mike |
|
|
michael.appleton
Posting Yak Master
160 Posts |
Posted - 2008-12-23 : 08:25:50
|
| I high lighted the wrong error earlier. I did edit it but then edited somethign else straight afterwards and it was over written. |
 |
|
|
michael.appleton
Posting Yak Master
160 Posts |
Posted - 2008-12-23 : 09:18:05
|
| Have rephrased question: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=116740 |
 |
|
|
|
|
|