Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-05-02 : 10:44:58
|
| Drew writes "I would like to use DTS to import from a text file. Some records will be duplicates of records that are alread in my destination table. I would like DTS to throw out duplicates while importing any new records. What I am finding is that when DTS comes across a duplicate, the whole import fails. I want to schedule this import to run on a regular basis. Thanks for any help you can give!" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-05-02 : 11:12:32
|
| Instead of using DTS to import directly into the destination table, have it import into a staging table, which has the same structure as the destination table. Then you can do something like this:DELETE FROM SFROM Staging S INNER JOIN Destination D ON S.ID=D.IDINSERT INTO Destination SELECT * FROM StagingThe ID column represents the primary key of the table, the JOIN will match any existing rows in the staging table and destination tables, and DELETE them from the staging table. Whatever is left over will be a new row, and the INSERT statement will put it into the destination table.Make sure that your DTS job has a DELETE FROM Staging step before it does the import, to clear out the staging table each time.Edited by - robvolk on 05/02/2002 11:13:23 |
 |
|
|
|
|
|