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.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 check for duplicate fields

Author  Topic 

batarsehs
Starting Member

9 Posts

Posted - 2005-06-20 : 12:22:43
I have the following problem:

I have the database on MS SQL database that has a table called "phones", which is the one that needs to be updated with the new phone numbers that I receive from clients every week.

The different clients send me the data in different file formats, example, XML, CVS, Excel and Text. as well as different column "field" naming.
I have an access database with a table for each client, where i import their files.

for now, In order to update the MS SQL phones table, I would need to choose the exact columns that i need from each file, and then insert them into MS SQL.

Therefore, i created an excel sheet where i paste all the colums needed from clients files, and then clean the spreadsheet for wrong phone number or null phone fields. Then i need to check that spreadsheet against the "phones" table in the MS SQL database for duplicate phone numbers, delete the duplicates and import the rest of phone numbers into the phones table

I am looking to make this process as automated as possible, especially the step of finding duplicate phone numbers in excel sheet that already exist in the MS SQL "phones" table.
Can you help me out, please.....



TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-06-20 : 12:56:24
>>especially the step of finding duplicate phone numbers in excel sheet that already exist in the MS SQL "phones" table

How about dumping all the numbers (including dupes) into a seperate sql server table. Then do a delete WHERE Exists statement. All remaining numbers can then be inserted.

Be One with the Optimizer
TG
Go to Top of Page

batarsehs
Starting Member

9 Posts

Posted - 2005-06-20 : 19:01:15
Thanks for the reply...
would it be possible to send me the SQL syntax that would accomplish deleting the dups and then inserting the rest of the data?
I am also new to stored procedures, but would i be able to store such process as a procedure that i would execute everytime i need to?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-21 : 03:43:52
Refer this link for exporting data to SQL Server from Excel
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

To delete duplicate records, refer this
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6256

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -