• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

restore db in sql server

I created a db and try to restore from the back up of another db.

i get the error
Restore of the db 'test2' failed. exclusive access could not be obtained.

please help thanks
0
TrialUser
Asked:
TrialUser
3 Solutions
 
Mike EghtebasDatabase and Application DeveloperCommented:
Are they the same version?
Are you logging as admin?
0
 
TrialUserAuthor Commented:
different version  -
yes i am logged in as administrator in sql management studio
0
 
Steve WalesSenior Database AdministratorCommented:
Before trying the restore, do this:

use master
go
alter database test2 set single_user with rollback immediate;

Open in new window

0
 
Anthony PerkinsCommented:
exclusive access could not be obtained.
It means that you or someone else is connected to the database on that server so you cannot overwrite.

different version  -
You cannot restore a backup from an a newer version pf SQL Server to a an older version of SQL Server.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
If you are trying to restore in the same stand-alone server then you'll see that error because you are trying to overwrite the database files. The solution is to Restore With Move option so you can set a new path for the data and log files. Example:
RESTORE DATABASE Test2 
FROM DISK = 'c:\mssql\backup\Test.bak'  --> replace with the real path and filename
WITH MOVE 'Test_Data' TO 'c:\mssql\data\Test2\Test2_Data.mdf', --> replace with the NEW real path and filename
MOVE 'Test_Log' TO 'c:\mssql\log\Test2\Test2_Log.ldf'  --> replace with the NEW real path and filename

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now