?
Solved

Best practice to remove destination rows before copy new rows from table to table?

Posted on 2010-09-01
3
Medium Priority
?
585 Views
Last Modified: 2013-11-30
I'm trying to get right the trivial use case of copying a table from one database to another.  In the Data Flow view I've got an OLE DB Source -> OLE DB Destination.   I want the destination table to be a mirror of the origin table.

The only problem is that every time I run it the flow appends instead of replacing the previous rows so my destination table size is 1x, 2x, 3x, 4x, etc.

New to SSIS, I don't understand why there isn't an option on the OLE DB Destination properties akin to "[x] Delete current rows before copy?," or even "replace instead of append," but, alas I don't see any feature like that.

What is the best way to remove the destination rows before the transfer?

Best thing I can figure out is to insert an Execute SQL Task to "truncate table MyDestination" ahead of the Data Flow Task that does the transfer.  Is that what everyone else does or did I miss something easy?
0
Comment
Question by:ZuZuPetals
[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 Comments
 
LVL 16

Accepted Solution

by:
carsRST earned 2000 total points
ID: 33582412
>>Best thing I can figure out is to insert an Execute SQL Task to "truncate table MyDestination" ahead of the Data Flow Task that does the transfer.  Is that what everyone else does or did I miss something easy?

You're right on the money.
0
 
LVL 16

Expert Comment

by:vdr1620
ID: 33582881
Well, you can definitely take that approach,But if there is any date column in the source and If only data is inserted into OLE DB source is then i would say use a SQL statement with a where clause instead of loading all the data again.. There's also an UPSERT Method which you can use to load the new rows and update any old values..If any values changed in your ole db source
0
 
LVL 30

Expert Comment

by:Reza Rad
ID: 33602456
just use an execute sql task before the Data flow task, and set sql statement as truncate table ....
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

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 …
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

718 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