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 |
|
ultraman
Starting Member
18 Posts |
Posted - 2004-06-18 : 11:34:03
|
| Hello all !I'm a total newbie to the DTS concept. I used the GUI of EM to build a DTS that transfer data from a data text files. There are 2 text files with the same structure going in the same destnation table.My problem is there is some duplicate keys in the second file. I would like to be able to import ONLY rows that doesn't already exists in the DB.I'm sure it's something stupid, but I really don't know how...Thanks !--------------Ultraman |
|
|
TurdSpatulaWarrior
Starting Member
36 Posts |
Posted - 2004-06-18 : 11:55:20
|
| Well, if you are sending this to a SQL table (which it sounds like), you can add another step to the DTS package and write a SQL script to remove the duplicates from the table. |
 |
|
|
ultraman
Starting Member
18 Posts |
Posted - 2004-06-18 : 12:22:16
|
| Well, the problem is there's a primary key that prevent the DTS to import the data in the first place. So I would have to check before every insert if there is already a row with this key in the table.--------------Ultraman |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-06-18 : 13:51:30
|
| Is the file the same every day?Do you need to know what's new, changed or gone?You'll need a staging table and then need to do compares.And learn bcp...Do you use Query Analyzer at all?You'll need to...and the sooner tyhe betterhttp://weblogs.sqlteam.com/brettk/archive/2004/04/23/1281.aspxBrett8-) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-06-18 : 13:54:57
|
| So import your data into a staging table as Brett mentioned, one that doesn't have a PK on it. Then you could delete the duplicates from the staging table using http://www.sqlteam.com/item.asp?ItemID=3331 then transfer the rows to your table.Tara |
 |
|
|
ultraman
Starting Member
18 Posts |
Posted - 2004-06-22 : 15:26:21
|
| Thank you all for your answers, I'll use this method and everything should be fine.--------------Ultraman |
 |
|
|
|
|
|