Skip to main content
Inspiring
April 9, 2008
Question

A better way?

  • April 9, 2008
  • 1 reply
  • 316 views
I have a SQL Server "Employee" table that I must update from an XML file periodically. Each month I receive a new XML file containing all of the company's employees. As you would imagine, there are some new employees in the list and some reporting relationships have changed. Other fields like department, and employee status may change for some employees as well.

Should I try and update the table or just delete the records in the table and do an insert from the XML file? Right now my code deletes the records from the table then adds the records back in using the XML file. The reason that I'm a little worried about this is because after the record delete, the entire table is laying exposed until the inserts start happening and if, something goes wrong with the insert, I'm left with an incomplete or empty table. Anyway, I'm just looking for an opinion here. Thanks very much.
This topic has been closed for replies.

1 reply

Inspiring
April 9, 2008
I'd use a working table. Delete and reinsert into the working table and then do whatever you have to do with your real tables using the working table as a reference.

The primary reason is to maintain the records of anyone who might not be in the xml file.
Winston2Author
Inspiring
April 9, 2008
Yep, that makes sense. I will do that.
Thanks.