Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

A better way?

Explorer ,
Apr 09, 2008 Apr 09, 2008
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.
TOPICS
Getting started
290
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 09, 2008 Apr 09, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 09, 2008 Apr 09, 2008
LATEST
Yep, that makes sense. I will do that.
Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources