0

I have inherited a database that has no real referential integrity at all, so I've created a new database with this corrected. The problem I have now, is that I have large amounts of data (around 50million rows) with previously assigned IDs. I need to keep these IDs in my new Database else I'll lose a lot of references from the data. So, initially I thought of turning off the Identity on the columns, and then insert the data and switch it on.

Does this sound like a feasible plan? Are there any flaws to this? Has anyone tried and tested it?

1 Answer 1

2

SET IDENTITY_INSERT ON is just for these cases. Don't forget to adjust identity counters after insert.

Sign up to request clarification or add additional context in comments.

4 Comments

So, by specifying IDENTITY_INSERT ON, this will keep my existing IDs from my old DB? This is kind of the crucial part of moving the data. Sorry for the idiocy, but I need to understand fully before I try and implement it :o)
If your insert query contains id column and values for it from the old DB, yes. This option allows inserting any values into identity columns as if they were ordinary columns.
@Ardman, read msdn.microsoft.com/en-us/library/aa259221(SQL.80).aspx for details. A small quote Allows explicit values to be inserted into the identity column of a table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.