I tried to restore a database using the following query:
ALTER DATABASE [DatabaseName] SET Single_User WITH Rollback Immediate GO
RESTORE DATABASE DatabaseName FROM DISK = 'C:\DBName-Full Database Backup'
ALTER DATABASE [DatabaseName] SET Multi_User GO
but instead of restoring the database, I am getting this error:
Msg 3159, Level 16, State 1, Line 2
The tail of the log for the
database “DatabaseName” has not been backed up. UseBACKUP LOG WITH NORECOVERYto backup the log if it contains work you do not want to
lose. Use theWITH REPLACEorWITH STOPATclause of theRESTORE
statement to just overwrite the contents of the log. Msg 3013, Level
16, State 1, Line 2RESTORE DATABASEis terminating abnormally.
The error message you are getting tells you exactly what you need to do if you don’t care about the existing database or log.
In SQL Server Management Studio (Tasks > Restore), you can add the
WITH REPLACEoption by opening the page “Options” on the left side and ticking “Overwrite the existing database”.