Solved

SSIS - Truncate table and import new data

Posted on 2007-11-13
6
7,768 Views
Last Modified: 2013-11-30
I am a total noob to SSIS...I am creating a new package that takes data from an OLE DB source and overwrites the data in another OLE DB source.  I set up my connections and dataflow tasks, but how do I truncate the destination table and import all of the data from the source?  Or would it be easier/better to just import any new records?
0
Comment
Question by:PsychoDazey
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:Yveau
ID: 20275506
If you can pinpoint only the new records it would make the network administrator a happy guy ... but that would imply having some kind of mechanism in place to keep track which records are 'new' on the source ... don't go verifying each record from the target and the source ...
In the package, include a task to delete the target table, that way you can go the easy way and copy everything over the line to the source ...

Hope this helps ...
0
 
LVL 6

Author Comment

by:PsychoDazey
ID: 20276552
Yveau - so you think I should drop the table and import it into the database?  How do I do that?  Do I need an oledbcommand between my source and destination?
0
 
LVL 18

Accepted Solution

by:
Yveau earned 250 total points
ID: 20276690
don't drop the table ! (that is removing it ... both data and table structure)
just empty it by 'delete from <yourtable>'

I would say an SQL task ... but I'm not very experienced with SSIS ...

hope this helps ...

0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 3

Assisted Solution

by:yellowjetski
yellowjetski earned 250 total points
ID: 20284586
Suggested Option 1: Full Migration (Easier but more traffic)
You can create a "Execute SQL" Task before your Data Migration Task and run the command "Truncate Table [Mytable]"

Suggested Option 2: Migrate only the new records. (There are more risks but better for the long run)
 - The source table must have a modified/created date stamp
For your data migration task, the Source SQL code should look like this: "select * from [source table] where [modified/created date] > (select max([modified/created date]) from [dest table])
0
 
LVL 6

Author Closing Comment

by:PsychoDazey
ID: 31409114
Thanks for the help, split points since you both contributed to the solution.
0
 
LVL 18

Expert Comment

by:Yveau
ID: 20292727
Glad I could be of any help !
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql query help 15 50
SCOM to SQL port 14xx failed? 1 29
Logical Operator should return Integer value in SSIS 9 34
sql query 5 38
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

685 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