I have clustered version of SQL Server 2014 for production, and for development I use SQL Server 2014 2014 Express edition.
I am facing problem while restore database backup from .bak
.
I get the following error every time I try to restore
TITLE: Microsoft SQL Server Management Studio
Restore failed for Server 'WEBDESIGNINA\SQLEXPRESS2014'. (Microsoft.SqlServer.SmoExtended)
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS2014\MSSQL\DATA\Database_Name.mdf'.
File 'Database_Name' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS2014\MSSQL\DATA\Database_Name.mdf'. Use WITH MOVE to identify a valid location for the file.
The operating system returned the error '32(The process cannot access the file because it is being used by another process.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS2014\MSSQL\DATA\Database_Name.ldf'.
File 'Database_Name_log' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS2014\MSSQL\DATA\Database_Name.ldf'. Use WITH MOVE to identify a valid location for the file.
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
RESTORE DATABASE is terminating abnormally. (Microsoft SQL Server, Error: 3634)
Only way to get around this problem is to delete the database & then restore to new database.
How can I overwrite this database without error
Happened with me too. Never seen this before. I took the DB offline, renamed the mdf/ldf, and started the restore, it is working now. Not sure if it is a good idea or not. But somehow I had to get this DB restored and move on.