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

Posted on 2014-08-21
Last Modified: 2016-02-11
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?
Question by:chrismichalczuk
    LVL 23

    Expert Comment

    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.
    LVL 44

    Expert Comment

    by: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
               'SELECT field1, field2 FROM databasename1.table1 )

    Open in new window

    LVL 14

    Accepted Solution


    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    My client sends a request to me that they want me to load data, which will be returned by Web Service APIs, and do some transformation before importing to database. In this article, I will provide an approach to load data with Web Service Task and X…
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now