Solved

SSIS - Truncate table and import new data

Posted on 2007-11-13
6
7,774 Views
Last Modified: 2013-11-30
I am a total noob to SSIS...I am creating a new package that takes data from an OLE DB source and overwrites the data in another OLE DB source.  I set up my connections and dataflow tasks, but how do I truncate the destination table and import all of the data from the source?  Or would it be easier/better to just import any new records?
0
Comment
Question by:PsychoDazey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:Yveau
ID: 20275506
If you can pinpoint only the new records it would make the network administrator a happy guy ... but that would imply having some kind of mechanism in place to keep track which records are 'new' on the source ... don't go verifying each record from the target and the source ...
In the package, include a task to delete the target table, that way you can go the easy way and copy everything over the line to the source ...

Hope this helps ...
0
 
LVL 6

Author Comment

by:PsychoDazey
ID: 20276552
Yveau - so you think I should drop the table and import it into the database?  How do I do that?  Do I need an oledbcommand between my source and destination?
0
 
LVL 18

Accepted Solution

by:
Yveau earned 250 total points
ID: 20276690
don't drop the table ! (that is removing it ... both data and table structure)
just empty it by 'delete from <yourtable>'

I would say an SQL task ... but I'm not very experienced with SSIS ...

hope this helps ...

0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 3

Assisted Solution

by:yellowjetski
yellowjetski earned 250 total points
ID: 20284586
Suggested Option 1: Full Migration (Easier but more traffic)
You can create a "Execute SQL" Task before your Data Migration Task and run the command "Truncate Table [Mytable]"

Suggested Option 2: Migrate only the new records. (There are more risks but better for the long run)
 - The source table must have a modified/created date stamp
For your data migration task, the Source SQL code should look like this: "select * from [source table] where [modified/created date] > (select max([modified/created date]) from [dest table])
0
 
LVL 6

Author Closing Comment

by:PsychoDazey
ID: 31409114
Thanks for the help, split points since you both contributed to the solution.
0
 
LVL 18

Expert Comment

by:Yveau
ID: 20292727
Glad I could be of any help !
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

737 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