Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to enable SSIS package to truncate the tables

Posted on 2014-02-11
5
Medium Priority
?
1,505 Views
Last Modified: 2016-02-10
I have an SSIS package that copies data from Oracle database to the SQL Server. It works fine but I would like it to truncate SQL Server tables prior to copying data. Is that possible to accomplish with SSIS? if so, how?
0
Comment
Question by:YZlat
  • 2
  • 2
5 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 1400 total points
ID: 39851048
Yes.  Prior to the data flow that pumps from Oracle to SQL, create an Execute SQL whose SQL code goes something like this:

TRUNCATE TABLE your_table_name

if we're talking more than one table, just repeat ...

TRUNCATE TABLE this_table
TRUNCATE TABLE that_table
0
 
LVL 35

Author Comment

by:YZlat
ID: 39851222
So I added "Execute SQL Task" to my Control Flow and linked it with Data Flow Task. Is that what you meant?
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39851235
Replace 'linked it' with 'so the green arrow goes FROM the Execute SQL Task TO the Data Flow Task', then yes.
0
 
LVL 34

Assisted Solution

by:Brian Crowe
Brian Crowe earned 600 total points
ID: 39851288
Considerations for using TRUNCATE TABLE:

Will not work on a table referenced by a Foreign Key constraint.  You must remove the constraint before executing TRUNCATE TABLE and then replace it after.

The table cannot participate in an indexed view.

The table cannot be published as part of transactional or merge replication.

The user executing the TRUNCATE command must have ALTER privileges on the target table or the user must have EXECUTE privileges on a procedure that executes the TRUNCATE.
0
 
LVL 35

Author Closing Comment

by:YZlat
ID: 39851494
Thanks! It worked
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how the fundamental information of how to create a table.

926 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