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
Solved

SSIS - Truncate table and import new data

Posted on 2007-11-13
6
7,766 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

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…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to shrink a transaction log file down to a reasonable size.
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.

790 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