Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • 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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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