Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to enable SSIS package to truncate the tables

Posted on 2014-02-11
5
Medium Priority
?
1,425 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 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

670 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