Link to home
Start Free TrialLog in
Avatar of Chris Michalczuk
Chris MichalczukFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SSIS insert / update question from one server table to a table on another server

I want to select some fields from a table on one server and automatically create them in another table on another server

so SSIS package needs to do following

select field1, field2 from server1.table1

delete from server2.table2

insert into server2.table2
values field1, field2
from server1.table1

what's the code / steps for doing this? I'm a bit lost! was thinking of a package in SSIS but is this more a stored procedure?
Avatar of rhandels
rhandels
Flag of Netherlands image

You can use a package for this. Making an SQL statement for the select of the old database is no problem. First create a OLDEDB Source and type in the correct statement you need to use.
After that, create an OLEDB destination, select the database you need to copy the information in. Either select an allready created database (if you have one) or ask it to create a new table for you.

Problem with this setup is that if you run the SSIS package it will add the information from your source to your destination and will add all records (not delete the old ones).

What i do now is just delete the information from the database. To do this you add an SQL execute statement task and type in delete from <destination_database>, then go to the data transormation task in which you tell it to copy info from source to destionation.
Avatar of Vitor Montalvão
You want to do it only once or in a regular way?

For a regular way and with schedules, then using SSIS will be a solution.

For one shoot only you can use Database Import/Export Wizard or T-SQL as:
INSERT INTO server2.table2
SELECT field1, field2 FROM
OPENROWSET('SQLNCLI',
           'Server='server1';Trusted_Connection=yes;
           'SELECT field1, field2 FROM databasename1.table1 )

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Vikas Garg
Vikas Garg
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial