Solved

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

Posted on 2010-09-01
3
583 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 500 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

710 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