[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SSIS - Truncate table and import new data

Posted on 2007-11-13
6
Medium Priority
?
7,803 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
[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
  • 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 1000 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 3

Assisted Solution

by:yellowjetski
yellowjetski earned 1000 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
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.
Viewers will learn how the fundamental information of how to create a table.

650 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