SQL error 4341, 4338 or 3013: Tips to fix

By Tech-Assured     
January 27, 2021  61 Views

SQL error 4341, 4338 or 3013: Tips to fix

Receiving errors while recovering database to a point in time?

Solution


Restore database with STOPAT

In order for this option to work, the database needs to be either in the FULL or Bulk-Logged recovery model and you need to be doing transaction log backups.

If you have a full backup and the transaction log has a minimally logged operation, you can try to do a point in time recovery using the commands below:

For example: If you wish to restore XYZfinancial database to at point in time equal to “August 27, 2010 at 8:42 PM”.

RESTORE DATABASE XYZfinancial FROM DISK =’C:\ XYZfinancial.BAK’

WITH NORECOVERY

GO

RESTORE LOG XYZfinancial FROM DISK = ‘C:\ XYZfinancial.TRN’

WITH RECOVERY, STOPAT = ‘Aug 27, 2010 08:42:00 PM’

GO

But if there are bulk operations, you will get the following error,
Msg 4341, Level 16, State 1, Line 1
This log backup contains bulk-logged changes. It cannot be used to stop at an arbitrary point in time.
Msg 4338, Level 16, State 1, Line 1
The STOPAT clause specifies a point too early to allow this backup set to be restored. Choose a different stop point or use RESTORE DATABASE WITH RECOVERY to recover at the current point.
Msg 3013, Level 16, State 1, Line 1
RESTORE LOG is terminating abnormally.

The restore operation will complete, but it will restore the entire transaction log backup and leave the database in a restoring state.  Now you can either restore additional transaction logs or use the RESTORE WITH RECOVERY option to bring the database back online.

SQL Server Management Studio

To restore to a point in time using SSMS:

Select the backup and the transaction logs you want to restore and then use the “To a point in time.” option recover the database to a selected point in time.

Our Support Engineers will assist you with all sorts of SQL related issues.