SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cannot Restore DB in SQL 2008
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

JR83
Starting Member

South Africa
31 Posts

Posted - 07/24/2013 :  01:54:56  Show Profile  Reply with Quote
Hi

I am trying to restore a .bak in SQL Server 2008 but i get the following message:

Exclusive access cannot be established as database is in use

I have checked the activity monitor and there is no one using the db, i have set it to use single user mode but still nothing.

Please can someone assist me with this query

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 07/24/2013 :  02:05:36  Show Profile  Reply with Quote
Are you trying to run restore by connecting to database? did you try it from master?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2217 Posts

Posted - 07/24/2013 :  02:15:03  Show Profile  Reply with Quote
quote:
Originally posted by JR83

Hi

I am trying to restore a .bak in SQL Server 2008 but i get the following message:
Exclusive access cannot be established as database is in use
I have checked the activity monitor and there is no one using the db, i have set it to use single user mode but still nothing.
Please can someone assist me with this query


These links might help you
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/aad41cbb-10cb-4109-9e55-aab048bbeb9d/exclusive-access-could-not-be-obtained-because-the-database-is-in-use
http://www.manjuke.com/2012/01/exclusive-access-could-not-be-obtained.html
--
Chandu

Edited by - bandi on 07/24/2013 02:16:45
Go to Top of Page

JR83
Starting Member

South Africa
31 Posts

Posted - 07/24/2013 :  02:23:03  Show Profile  Reply with Quote
I am restoring over an existing database or a new database. but whatevcer i try nothing works
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 07/24/2013 :  02:26:20  Show Profile  Reply with Quote
quote:
Originally posted by JR83

I am restoring over an existing database or a new database. but whatevcer i try nothing works


whats the current database context from which you're running this on? you should be running restore from master db.

Also try

ALTER DATABASE yourdbname SET offline WITH ROLLBACK IMMEDIATE;


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

JR83
Starting Member

South Africa
31 Posts

Posted - 07/24/2013 :  02:35:15  Show Profile  Reply with Quote
I have tried all the above regarding those links and nothing works.
Go to Top of Page

JR83
Starting Member

South Africa
31 Posts

Posted - 07/24/2013 :  02:38:21  Show Profile  Reply with Quote
i tried this script:

alter database database_name
set offline with rollback immediate
alter database database_name
set online

then i got this message: The backup set holds a backup of a database other than the existing 'q' database.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 07/24/2013 :  02:41:16  Show Profile  Reply with Quote
quote:
Originally posted by JR83

i tried this script:

alter database database_name
set offline with rollback immediate
alter database database_name
set online

then i got this message: The backup set holds a backup of a database other than the existing 'q' database.


hmm..so you were trying to restore a db from a backup of different db?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2217 Posts

Posted - 07/24/2013 :  02:42:53  Show Profile  Reply with Quote
quote:
Originally posted by JR83


then i got this message: The backup set holds a backup of a database other than the existing 'q' database.



solution:
http://blog.sqlauthority.com/2007/09/27/sql-server-fix-error-3154-the-backup-set-holds-a-backup-of-a-database-other-than-the-existing-database/
http://www.linglom.com/it-support/solved-system-data-sqlclient-sqlerror-the-backup-set-holds-a-backup-of-a-database-other-than-the-existing-dbname-database/
--
Chandu

Edited by - bandi on 07/24/2013 02:46:19
Go to Top of Page

JR83
Starting Member

South Africa
31 Posts

Posted - 07/24/2013 :  02:46:54  Show Profile  Reply with Quote
yes, i have a backup from a client that i want to restore locally on my computer
Go to Top of Page

JR83
Starting Member

South Africa
31 Posts

Posted - 07/24/2013 :  02:58:28  Show Profile  Reply with Quote
now i am running this:

ALTER DATABASE MembersDatabase
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE

RESTORE DATABASE MembersDatabase
FROM DISK = 'd:\MembersDatabase_20130717_01.bak'
WITH REPLACE

and i still get: Exclusive access could not be obtained because the database is in use.

NOTHING is working.. back at the same issue
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2217 Posts

Posted - 07/24/2013 :  03:31:40  Show Profile  Reply with Quote
Follow this method once...
1)Check whether there exist active process for the database which you want to restore....
EXEC sp_who;
2) KILL the active processes
KILL SPID; -- put spid of your database
3) Refresh and re-run the EXEC sp_who; command again to check if the process has been killed.
4) Then try RESTORE (Restore it from Backup )

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000