Thursday, September 27, 2012

SQL: Restore Database Error

Sometime it happens that if you try to restore the database backup then you get this kind of error:

// ***************************************************************************
TITLE: Microsoft SQL Server Management Studio Express
------------------------------

Restore failed for Server 'MY-PC\SQLEXPRESS'.  (Microsoft.SqlServer.Express.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Restore+Server&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

System.Data.SqlClient.SqlError: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\testdb.mdf'. (Microsoft.SqlServer.Express.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

//********************************************************************************

Don't worry at all I am going to tell you how to resolve this issue using screen shot.

Just see below screen shot and you will get to know how to do it.

Step 1: Restore Database Window:




Step 2: Restore Database Error


Step 3: Restore Database Error Fixing:


In the above screen shot change the paths for the MDF and LDF file with following location:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\testdb.mdf
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\testdb.ldf

Click OK and your database will get restore successfully.


No comments:

Post a Comment