We restore a database daily that we download from an FTP site. I would like to build a history table that tracks when the database is restored on our SQL Server. This is easy. My issue is sometime the download is incomplete and therefore the restore does not work and throws an error. I would like to add logic to my history process to insert failed if the restore fails. Not sure how to handle this logic and am looking for assistance.
This is the error we get most frequently when the failure occurs.
Error: 3266, Severity: 16, State: 1. The backup data at the end of "F:\Backups\DB.bak" is incorrectly formatted. Backup sets on the media might be damaged and unusable. To determine the backup sets on the media, use RESTORE HEADERONLY. To determine the usability of the backup sets, run RESTORE VERIFYONLY. If all of the backup sets are incomplete, reformat the media using BACKUP WITH FORMAT, which destroys all the backup sets.