Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cannot Restore DB in SQL 2008

Author  Topic 

JR83
Starting Member

31 Posts

Posted - 2013-07-24 : 01:54:56
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

52326 Posts

Posted - 2013-07-24 : 02:05:36
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-07-24 : 02:15:03
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
Go to Top of Page

JR83
Starting Member

31 Posts

Posted - 2013-07-24 : 02:23:03
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

52326 Posts

Posted - 2013-07-24 : 02:26:20
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

31 Posts

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

JR83
Starting Member

31 Posts

Posted - 2013-07-24 : 02:38:21
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

52326 Posts

Posted - 2013-07-24 : 02:41:16
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-07-24 : 02:42:53
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
Go to Top of Page

JR83
Starting Member

31 Posts

Posted - 2013-07-24 : 02:46:54
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

31 Posts

Posted - 2013-07-24 : 02:58:28
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
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-07-24 : 03:31:40
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
   

- Advertisement -