Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overwrite certain fields that are imported 1

Status
Not open for further replies.

jh3016

Programmer
Jun 6, 2003
148
US
I need to import some data that has been updated. The problem is that some of the fields currently exist. I need to search for two fields, if they match, then update some other fields.

I'm hoping there is a quick way to do this. And I need help fast.

Thanks in advance.
 
So you are importing from an outside source into a table, and have to check that import against another table then update?

Give me more information and I will try to help.

ChaZ

Ascii dumb question, get a dumb Ansi
 
I was given a database that had employee counts and company names. Now the company names still exist and are a match, however, the employee counts have been updated. Is there a way to say: "Look for the exact match of company and then update the new employee count"?

Thanks in advance. This will save the day!
 
Certainly.

Say you have a table called TableToUpdate, and it looks like this

Company Count
IBM 0
Apple 0
Commodore 0
Atari 0

And you want it updated from another table called UpdatedData, which looks like this:

Company Count
IBM 8
Apple 6
Commodore 7
Atari 5

You could update your first table with the following query. Even if there is more data in the second table, it will only update exact matches.

UPDATE TableToUpdate INNER JOIN UpdatedData ON TableToUpdate.Company = UpdatedData.Company SET TableToUpdate.[Count] = [UpdatedData].[count];

Hope that helps.

ChaZ


Ascii dumb question, get a dumb Ansi
 
Thank you so much. This worked like a charm!!!!!!!!

I'm giving you a star!
 
Well thank you very much. Glad I could help.

ChaZ

Ascii dumb question, get a dumb Ansi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top