Solved

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

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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 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 and will be exposed to the many uses the SELECT statement has.

770 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