Highlighted

Copy table data from one server to another

New Here ,
Sep 10, 2015

Copy link to clipboard

Copied

Hi,

   I have two tables T1 and T2 of same structure at two different sql servers.T1 has 1,00,000 records and T2 has 99,000 records. Is it possible to copy

the extra records(1000 records) from table T1  to T2 which are not present in T2. Read about linked server. Is there any other alternative ways?

Thanks

TOPICS
Getting started

Views

376

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Copy table data from one server to another

New Here ,
Sep 10, 2015

Copy link to clipboard

Copied

Hi,

   I have two tables T1 and T2 of same structure at two different sql servers.T1 has 1,00,000 records and T2 has 99,000 records. Is it possible to copy

the extra records(1000 records) from table T1  to T2 which are not present in T2. Read about linked server. Is there any other alternative ways?

Thanks

TOPICS
Getting started

Views

377

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 10, 2015 0
BKBK LATEST
Adobe Community Professional ,
Sep 10, 2015

Copy link to clipboard

Copied

An idea comes to mind immediately. Backup your tables before you do anything. Then, whatever happens, you will be able to return them to their original state.

The idea goes as follows. Copy T1 to the server that has T2. On this server, do the following

INSERT INTO T2

SELECT T1.*

FROM T1

WHERE T1.PKCol NOT IN

    (SELECT T2.PKCol

     FROM T2)

The idea is straightforward. You use the primary key to get the 1000 records that are in T1 but not in T2, and insert them in T2.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 10, 2015 1