Solved

How to enable SSIS package to truncate the tables

Posted on 2014-02-11
5
1,203 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 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query Optimization 14 42
Server running out of memory - Something is consuming all the available memory 17 58
SQL Server Generate Scripts Fails 5 35
SQL View nearest date 5 35
My client sends data in an Excel file to me to load them into Staging database. The file contains many sheets that they have same structure. In this article, I would like to share the simple way to load data of multiple sheets by using SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

776 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