I have one simple stored procedure to select, format and copy records from TimeCard database to our ERP database. Both are SQL Servers.
It is running on SQL Server Agent as a scheduled job. The code look like this
INSERT INTO linked_erpserver.db.SCHEMA.table01
SELECT *
FROM linked_timecardserver.db.SCHEMA.tablexx X
WHERE X.flag = 0
UPDATE linked_timecardserver.db.SCHEMA.tablexx
SET flag = 1
WHERE flag = 0
Now, suppose if there is a big number of records and connection to linked servers are failed, it will be catastrophic effect.
How can I deal with this? Should I select records one by one, insert, update and commit that one record.
EDIT: We are using SQL Server 2005