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 |
|
ELLIEMAY
Starting Member
43 Posts |
Posted - 2004-08-05 : 16:33:55
|
Okay I have a DTS setup to import data from a text file into a table and it works great, but I would like it to compare the data prior to the import and only import the data that has a match in a seperat table. So, say I have listTABLE and matchTABLE. I would like only the records in my import file that hav a match in listTABLE to be inserted in matchTABLE. Any advice would be G R E A T!!!!! Thanks in advance. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-08-05 : 16:51:57
|
| Import the data into a staging table. Staging table would have same table structure as destination table. Then use T-SQL to get the data from staging to destination. If we knew more information about your data and tables, then we'd be able to help you write the T-SQL query.Tara |
 |
|
|
ELLIEMAY
Starting Member
43 Posts |
Posted - 2004-08-05 : 18:01:35
|
| Okay. I will import into a staging table called importTABLE. The file is a .csv file with about 5 fields(fname,lname,dob,ssn,other).It is saved in C:\ftp_test on the server. So when I get importTABLE populated, I need only the records in it that have a matching SSN to go to matchTABLE. Then I need importTABLE to clear for the next import. Thanks SO much for your help. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-08-05 : 18:04:04
|
| INSERT INTO matchTable(fname, lname, dob, ssn, other)SELECT i.fname, i.lname, i.dob, i.ssn, i.otherFROM importTable iINNER JOIN listTable lON i.ssn = l.ssnDELETE FROM importTableTara |
 |
|
|
|
|
|
|
|