• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 691
  • Last Modified:

Flat file to Insert Update

Hi I have a flat file of 400,000 records.

I have an existing table that matches the flat file. This wil be the second time I read the data in. The first time the table was empty. This time the table is full and about 10% of the fields will be new, 10% will need to be update. How can I read through the flat file and decide if the key already exists. If it does I want to update the table if it does not I want to insert the data into the table.  I do not know ahead of time which frows will have changes data so if I need to do every record that exists and update it thats ok.

This is a once every quarter update speed is not an issue.
Charles Baldo
Charles Baldo
  • 2
2 Solutions
Aneesh RetnakaranDatabase AdministratorCommented:
You can probably copy the data into a temptable first, then you can update the values which are there in the master table and insert the new values from the temptable using an 'EXISTS' clause
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I agree: load the flat file into a "staging" table, and from there (after creating eventual indexes), update the production table.
if you need help on how to formulate the update/insert queries accordingly, or how to load the file into a table (BULK INSERT), ask.
Charles BaldoSoftware DeveloperAuthor Commented:

I understand its difficult to know exactly what the issue is and whats in a programmers mind. But ocassional it happens. Below is a link of almost exactly my issue and it was solved. The steps suggested by the experts were used. Thank both I will split the points.

Charles BaldoSoftware DeveloperAuthor Commented:
Thank You all I did give an excellent grade because I appreciate the quick response. However the solution was only a partial.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now