Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

My backup file in C:\DatabaseBackup\ABC.bak, I am restoring database from this backup file.It's showing the error only in windows 7.

I have a windows service for database restore but it's not running successfully, it's showing the error.

How will be solved this problem?
Please help me urgently.

Start Service
Error: Microsoft.SqlServer.Management.Smo.FailedOperationException: Restore failed for Server 'USER-PC\SQLEXPRESS'.  ---> Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> System.Data.SqlClient.SqlException: User does not have permission to RESTORE database 'ABC'.
RESTORE DATABASE is terminating abnormally.
   at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
   at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
   --- End of inner exception stack trace ---
   at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
   at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
   at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
   at Microsoft.SqlServer.Management.Smo.BackupRestoreBase.ExecuteSql(Server server, StringCollection queries)
   at Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
   --- End of inner exception stack trace ---
   at Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
   at DownloadDatabaseService.DBRestore.RestoreDatabase(String backupFile)
   at DownloadDatabaseService.DBRestore.OnElapsedTime(Object source, ElapsedEventArgs e)


Please help me urgently.

Thank You.
Ankit Agarwal
Software Engineer
Posted
Updated 10-Feb-13 22:53pm
v2
Comments
Maciej Los 11-Feb-13 4:56am    
Do you use custom software or SSMS?
What kind of version of Win7 (32 or 64 bit)?
What kind of version of MS SQL Server (2k5, 2k8, 2012)?
[no name] 11-Feb-13 5:01am    
Windows 7 64-Bit
SQL SERVER 2008
Guirec 11-Feb-13 5:30am    
Just an idea... Create a user in the destination machine with the same login as the one who was 'owning' the backed-up database...

1 solution

From the error message you have given it shows the user credentials under which the service is running does not have the permission to restore the permission.
So please ensure that this user has the sufficient privileges to restore a database on the SQLServer instance that you are connecting to.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900