SQL Error System.Data.SqlClient.SqlError: 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'

Hi all,

While Restoring a SQL Backup from SQL Server Management Studio sometime we get an error as shown below -


System.Data.SqlClient.SqlError: 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\SQL\Databases\\TestDB_2012_10.mdf'. (Microsoft.SqlServer.Smo)




Cause of Error
we typed the name incorrectly during the file name creation in Restore Operation.

Resolution -


Check out the file name in Option tab of Restore Database window.
You would have put two \\ instead of one while specifying the path where file should get created.

Below is the image of what i did -



Thanks & Regards,
Saurav Dhyani
http://saurav-nav.blogspot.com/