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 useI 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 MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
|
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 |
|
|
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 MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
JR83
Starting Member
31 Posts |
Posted - 2013-07-24 : 02:35:15
|
I have tried all the above regarding those links and nothing works. |
|
|
JR83
Starting Member
31 Posts |
Posted - 2013-07-24 : 02:38:21
|
i tried this script:alter database database_nameset offline with rollback immediatealter database database_nameset onlinethen i got this message: The backup set holds a backup of a database other than the existing 'q' database. |
|
|
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_nameset offline with rollback immediatealter database database_nameset onlinethen 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 MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
|
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 |
|
|
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 IMMEDIATERESTORE DATABASE MembersDatabase FROM DISK = 'd:\MembersDatabase_20130717_01.bak' WITH REPLACEand i still get: Exclusive access could not be obtained because the database is in use.NOTHING is working.. back at the same issue |
|
|
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 |
|
|
|