Patrick Miller
asked on
Trying to restore database in Enterprise Manager and I get error
I am attempting to restore f:\sqldata\mydatabasebacku p to my mydatabase.mdf file in Enterprise Manager and I get this error "Exclusive access could not be obtained because the database is in use. Restore database is terminating abnormally."
I tried to take it offline and it failed with an error 5070.
What do I need to do to get exclusive use and to get this restore done.
I tried to clear connections when I Detached the database but when I reattached it the connection was back.
Thanks for any help.
I tried to take it offline and it failed with an error 5070.
What do I need to do to get exclusive use and to get this restore done.
I tried to clear connections when I Detached the database but when I reattached it the connection was back.
Thanks for any help.
Where is the connection from? Is it, perhaps, you? (Do *not* expand the DB in enterprise manaqger, do *not* look at any data in it).
If the connection is not you, then who / where is it / is it from?
If the connection is not you, then who / where is it / is it from?
Or use QA:
ALTER DATABASE myDatabase
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE myDatabase
FROM FILE = 'f:\sqldata\mydatabaseback up'
WITH REPLACE
--* next lines are optional, if you want to restore to a different file name
-- ,MOVE 'logical_mdf_name' TO 'f:\data\<mdf_file_name>.m df'
-- ,MOVE 'logical_log_name' TO 'f:\log\<log_file_name>.ld f'
ALTER DATABASE myDatabase
SET MULTI_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE myDatabase
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE myDatabase
FROM FILE = 'f:\sqldata\mydatabaseback
WITH REPLACE
--* next lines are optional, if you want to restore to a different file name
-- ,MOVE 'logical_mdf_name' TO 'f:\data\<mdf_file_name>.m
-- ,MOVE 'logical_log_name' TO 'f:\log\<log_file_name>.ld
ALTER DATABASE myDatabase
SET MULTI_USER WITH ROLLBACK IMMEDIATE
ASKER
Checking the 3 box didn't help.
Using QA gets stuck on the syntax line 5 the backup file is called pam_mast_data_dump.dat
ALTER DATABASE pam_mast
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE pam_mast
FROM FILE = 'f:\sqldata\pam_mast_data_ dump'
WITH REPLACE
--* next lines are optional, if you want to restore to a different file name
-- ,MOVE 'logical_mdf_name' TO 'f:\data\<mdf_file_name>.m df'
-- ,MOVE 'logical_log_name' TO 'f:\log\<log_file_name>.ld f'
ALTER DATABASE pam_mast
SET MULTI_USER WITH ROLLBACK IMMEDIATE
Using QA gets stuck on the syntax line 5 the backup file is called pam_mast_data_dump.dat
ALTER DATABASE pam_mast
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE pam_mast
FROM FILE = 'f:\sqldata\pam_mast_data_
WITH REPLACE
--* next lines are optional, if you want to restore to a different file name
-- ,MOVE 'logical_mdf_name' TO 'f:\data\<mdf_file_name>.m
-- ,MOVE 'logical_log_name' TO 'f:\log\<log_file_name>.ld
ALTER DATABASE pam_mast
SET MULTI_USER WITH ROLLBACK IMMEDIATE
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I still get this error.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Server: Msg 3101, Level 16, State 1, Line 4
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 4
RESTORE DATABASE is terminating abnormally.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
Server: Msg 3101, Level 16, State 1, Line 4
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 4
RESTORE DATABASE is terminating abnormally.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks, bhess1. I hadn't run into that issue yet and so didn't realize it.
Force restore over existing database.
I think this will do the job