Script to provide backup sequence with the shortest restore time - Interview Question


You may be working in a team and there are scenarios where database backups are generated on an adhoc basis. Taking database backups in an adhoc manner breaks a backup plan that is scheduled in an production environment (We are not talking about COPY_ONLY backups). Later, it is difficult to keep a track and identify the right backup sequence to perform restore.
This script will help you to retrieve information about Full, Differential and Log backups for the databases residing on the same instance. It also shows the backup chain that will help us to restore this databases in the shortest time.
This question was asked to me during an interview.