Solved

restore db in sql server

Posted on 2015-02-07
6
186 Views
Last Modified: 2015-05-19
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
Comment
Question by:TrialUser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 167 total points
ID: 40596283
Are they the same version?
Are you logging as admin?
0
 

Author Comment

by:TrialUser
ID: 40596285
different version  -
yes i am logged in as administrator in sql management studio
0
 
LVL 22

Assisted Solution

by:Steve Wales
Steve Wales earned 167 total points
ID: 40596467
Before trying the restore, do this:

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

Open in new window

0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 166 total points
ID: 40597481
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
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 40598266
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question