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 |
|
rafael.javellana
Starting Member
10 Posts |
Posted - 2011-06-01 : 18:27:02
|
| Good Day guys, I need help, I have a table "List" that everyday I import records on it, the key field is "Phone". The problem is everyday the records I imported has a duplicates that exist on the previous batch of list/records. My questions is how can I update the new records if it is already existing on the previous batch of records and it is also on the new batch that I have to import. Actually I import data on the table "List" without checking duplicates since it is requested by the client.Here's the logic:1. Import "ListNEW" to "ListOLD"2. Check if field "Phone" from "ListNEW" exist on the "Phone" on "ListOLD"3. If #2 is TRUE, then update the "Lock" field of "ListNEW" based on "Phone" field from "ListOLD".Thanks.rfjavellana |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
rafael.javellana
Starting Member
10 Posts |
Posted - 2011-06-02 : 17:20:15
|
| Hi Tara first of all thank you.Here is the table sample:ListOLDName Phone LockLarry 1234567890ListNEWName PhoneLarry 1234567890If after importing, the record on ListNEW exist based on field "Phone" on the ListOLD table, the field "Lock" on ListOLD table will be updated for the record just imported from ListNEW, so this will be the data on the table ListOLD after the process:ListOLDName Phone LockLarry 1234567890 1Larry 1234667890 2Thanks.rfjavellana |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-06-03 : 12:02:31
|
| how did it end up having two records after update? i think what you want is insert------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
rafael.javellana
Starting Member
10 Posts |
Posted - 2011-06-03 : 14:55:39
|
| the record is from ListNEW, I will IMPORT it to ListOLD then there will be two same record, my question is after the import, how can I check if the record from ListNEW already exist on the ListOLD, if it exist, the query will update the lock field for the duplicate records.Thanks.rfjavellana |
 |
|
|
rafael.javellana
Starting Member
10 Posts |
Posted - 2011-06-03 : 18:13:36
|
| by the way, shall I say ListOLD will be replace by TableOld and ListNEW will be replace by FileA, just to make my questions more clearer.Thanks.rfjavellana |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|