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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare SQL table data with that in a txt file

Status
Not open for further replies.

csmanohar

Programmer
Apr 4, 2000
7
US
I have a SQL server 7.0 table that needs to be updated every time there is a transmission
from our client.
This transmission is in the form of a txt file containing the most current
data.
I need to compare the file with the data currently in the table, identify
the differences, and create a transaction table that can be used to update
the master table after user approves the updates.

My question is this: What is the best/most elegant way to compare the file
data with the table data? The transmission is fairly large, so the
comparison has to be efficient. Is there any proven technique to accomplish
something like this.
Thanks for any suggestions.
 

I would create a stored procedure to do the following.[ol][li]Transfer the text file to a table in SQL Server using Bulk Insert.
[li]Run a mismatch query to compare the imported table to the master table and insert the differences into the transaction table.[/ol]This should be fairly efficient. I choose to do this in a stored procedure because of my familiarity with T-SQL. Someone else might choose a DTS solution while another might choose to BCP the data in the text file to SQL Server and then create the transaction table via OSQL or ISQL. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top