SQL Server Data Migration-identify repetitive simple processing

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.