Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2014-08-21
Medium Priority
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:Chris Michalczuk
LVL 23

Expert Comment

ID: 40276108
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 53

Expert Comment

by:Vitor Montalvão
ID: 40276334
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 15

Accepted Solution

Vikas Garg earned 2000 total points
ID: 40280421

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

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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
Suggested Courses

578 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