Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving data from one database to another

Status
Not open for further replies.

smileydba

Programmer
Jun 21, 2005
15
0
0
US
Another Newbie Q

Old Database-->table/data--->Move into new database--->table

So basically, what we want is basically, the old database has some data we want to move to the new database. But here is the kicker, the new database already has data in the table we want to move data to. So basically, is there a scripts that does kinda the following,

if a column matchs between the old table and new table,
skip
but if the column from the old table isent in the new,
Add

I see that DTS could do this, but could TSQL do this?? And if so, what would the code be.

Rob W.
 
Also, basically, dont want any duplicates or the old data over writing the new data.


Rob W.
 
You could simply add all data from the old table to the new, and then generate a script to remove all duplicates....
 
Ok, if that is done, how would I write up the Update statement to where the old data(the data that was passed over by the old database) would be deleted instead of the new data?


Rob W.
 
Hmm, yes, good point....

Perhaps add a column which states which DB the data is from, and if there are duplicates, delete all the duplicates where NewColumn = Old?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top