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?
Chris MichalczukConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rhandelsCommented:
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.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
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

0
Vikas GargBusiness Intelligence DeveloperCommented:
Hi,

In SSIS you can have package having Data flow task and Execute sql task.

First DFT - Data flow task will load data from Server1.table1 to Server2.table2 and then execute sql task to delete rows from server1.table1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.