Summary article: Http://www.cnblogs.com/dunitian/p/4822808.html#tsql
Today in the data migration because the hands of the cheap encounter a pit dad problem, sent to everyone happy, also teach novice point experience
Migration is usually a temporary table or a new library, often using a lot of syntax, this is mainly said this:select * into the database name. Table name from XXX
First of all, look at the error:
Hurry to see if the data is duplicated ~ It turns out that wood has duplicate data ...
Some people will ask, how do you ask for count? Well, I will. is the most basic method, the common two kinds of actually the same performance, contrast chart: ( There is a better way to mention the little brother ^_^)
Come on, check the data under Change ID: In the end is not repeating ~ ~ ~ not ...
Okay, let's see the same ID repeat number.
Think carefully, the whole process of migration, seemingly what is wrong with wood, is this the reason why the hand is cheap?? (The command did not finish, point a few times to accelerate, do not know if this is the cause of the cause, okay, it's him. = = = "( ̄- ̄))
Workaround: Two, one is to re-organize the data migration
The second is the ID first deleted, and then built (because the data is not a problem, if the data is wrong, then you have to repeat it anyway)
Script:
ALTER TABLE Info01 drop column Id
Go
ALTER TABLE INFO01 add Id int identity (primary) key
Go
Now we finally know why a lot of the database's primary keys are in the last column
At the end of the recommendation, it is best to use the program to control and process the data (you have to make sure that the logo is unique), and if you do whatever it is
SQL Server Data Migration-identify repetitive simple processing