Solved

SSIS - Truncate table and import new data

Posted on 2007-11-13
6
7,748 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
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…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now