Backup is the key to perform recovery of database objects after the corruption of database file. SQL Server provides you with a number, Log Sequence Number (LSN), which during the process of database restoration is used as a recovery point.
LSN also helps you perform differential backup. When you perform differential backup, a bitmap corresponding to that backup is generated. All changes made during the backup are marked in that bitmap, otherwise database errors are generated.
With the help this differential backup, one can easily recover database objects from damaged database. However, sometimes during the restoration process you may receive following error message:
Server: Msg 2515, Level 16, State 1
Page P_ID, object ID O_ID, index ID I_ID has been modified but is not marked modified in the differential backup bitmap.
It has a symbolic name DBDC_DIFF__MAP__OUT_OF_SYNC
Explanation of SQL error 2515
The error specifies that the page has a higher LSN compared to the differential reference LSN or the differential base LSN. But in the differential backup bitmap, the page is not shown as modified.
Solutions for SQL error 2515
This error is displayed when the change in LSN and differential base LSN in FCB or differential reference LSN in Backup Manager is not marked in bitmap. It is not easy to restore the database which has been corrupted. Following steps can help you recover the database:
Check for hardware faults
If the issue arises due to some hardware related reasons, it can easily be resolved by changing the hardware. You can check the system, application logs, and SQL error logs to find the exact issue. Then try changing the faulty hardware components or the entire hardware.
Restore from backup
If SQL server notifies the error even after changing the hardware, then try to restore the database from a good backup available.
Run DBDC CHECKDB
If no useful backup available, run DBDC CHECHDB without a repair clause. It will help you asses the error situation and its magnitude. Later you can run the DBDC CHECKDB with this REPAIR clause to fix the issue. However, you should expect the possibility of data loss in this case.
Try SQL Recovery tools
Running the DBDC CHECKDB tool can cause data loss which is not desirable. To avoid such situations, there is an effective data recovery tool named Kernel for SQL Database Repair. It can repair corrupted MDF/NDF files of all sizes. It can perform a smooth recovery with the database files of all SQL versions.