I wish to migrate information from one database to a different. The desk schemas are precisely the identical:
CREATE TABLE Prospects( [Id] INT NOT NULL PRIMARY KEY IDENTITY, (another columns ......) ); CREATE TABLE Orders( [Id] INT NOT NULL PRIMARY KEY IDENTITY, [CustomerId] INT NOT NULL, (another columns ......), CONSTRAINT [FK_Customers_Orders] FOREIGN KEY ([CustomerId]) REFERENCES [Customers]([Id]) )
The 2 databases have completely different information, so the brand new id key for a similar desk can be completely different on the two databases. That isn’t an issue; my objective is to append new information to the present one, not full changing all information of the complete desk. Nonetheless I want to preserve all parent-child relationship of the inserted information.
If I exploit the “Generate Script” function of SSMS, the script would try to insert utilizing the identical ID, which might battle current information within the vacation spot database. How can I copy information utilizing database scripts solely?
I would like the id column on the vacation spot to proceed usually from its final worth.
Prospects doesn’t have every other
UNIQUE NOT NULL constraint. It’s alright to have duplicate information in different columns (I am utilizing
Orders simply for instance right here, so I haven’t got to clarify the entire story). The query is about any one-to-N relationship.