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
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 UPDATE/APPEND QUERY HELP ...

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-10-30 : 08:47:27
RALPH NOBLE writes "First, thanks for reading ... As to my needs, I obtain a flat text file each month that includes both new records and updated records. Each row has a unique ID called ID. I have created a DTS package that imports the flat text file and places it in a temporary table called NEWDATA. I then need to ...

1. UPDATE QUERY: Link the two databases (where NEWDATA.ID = OLDDATA.ID) and update the existing fields that changed.

2. APPEND QUERY: Link the two database (where NEWDATA.ID <> OLDDATA.ID) and append the new records from NEWDATA.

Again, only two types of records can appear in the flat text file: The ID is either a new record or is an update to an existing record and thus all fields must be updated in the OLDDATA table.

Any suggestions on how I can accomplish this?

Thanks,

Ralph Noble
ralph_noble@hotmail.com"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-10-30 : 08:56:57
You've pretty much got it figured out. You could also do this:

A. Delete the rows from OLDDATA where OLDDATA.ID=NEWDATA.ID
B. Insert all of the rows from NEWDATA into OLDDATA

Since they're either new or updated rows, deleting any common rows between the two and then inserting everything will guarantee that the entire file is processed correctly. You won't need to compare each column to see which ones were updated or not, or even individually update each column.

Go to Top of Page
   

- Advertisement -