Solved

How to enable SSIS package to truncate the tables

Posted on 2014-02-11
5
1,278 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
[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
  • 2
  • 2
5 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 350 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 65

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 150 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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.

752 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