Tuesday, March 27, 2012

Can't get exclusive access

While attempting to restore a db, I get the following error message:
"RESTORE DATABASE is terminating abnormally.
Exclusive access could not be obtained because the database is in use."
But looking at Current Activity in EM, I see nothing logged into the
database. The database I am restoring to is set to Single-User. Any
suggestions?
SQL 2000, sp4
Thanks,
SteveRunning the statement first
ALTER DATABASE <Nameofthedb> SET SINGLE_USER with rollback immediate
If you want to do that from Query Analyzer, make sure that you cursor is NOT
positioned on the DB node you want to restore.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Steve Deering" <Steve@.vin.com> schrieb im Newsbeitrag
news:1118060114.644682.280310@.g43g2000cwa.googlegroups.com...
> While attempting to restore a db, I get the following error message:
> "RESTORE DATABASE is terminating abnormally.
> Exclusive access could not be obtained because the database is in use."
> But looking at Current Activity in EM, I see nothing logged into the
> database. The database I am restoring to is set to Single-User. Any
> suggestions?
> SQL 2000, sp4
> Thanks,
> Steve
>|||If it still complains, disconnect all your EM sessions.
"Steve Deering" <Steve@.vin.com> wrote in message
news:1118060114.644682.280310@.g43g2000cwa.googlegroups.com...
> While attempting to restore a db, I get the following error message:
> "RESTORE DATABASE is terminating abnormally.
> Exclusive access could not be obtained because the database is in use."
> But looking at Current Activity in EM, I see nothing logged into the
> database. The database I am restoring to is set to Single-User. Any
> suggestions?
> SQL 2000, sp4
> Thanks,
> Steve
>|||Hi,
Try the below:-
1. From Query analyzer set the database to SINLE USER.
USE MASTER
GO
ALTER DATABASE <DBNAME> SET SINGLE_USER with rollback immediate
2. Restore the database
RESTORE DATABASE <DBNAME> FROM DISK='FILENAME WITH PATH' WITH STATS=10
Incase if the restore still fails then, close the query analyzer fully once
and try the RESTORE DATABASE again.
Thanks
Hari
SQL Server MVP
"Steve Deering" <Steve@.vin.com> wrote in message
news:1118060114.644682.280310@.g43g2000cwa.googlegroups.com...
> While attempting to restore a db, I get the following error message:
> "RESTORE DATABASE is terminating abnormally.
> Exclusive access could not be obtained because the database is in use."
> But looking at Current Activity in EM, I see nothing logged into the
> database. The database I am restoring to is set to Single-User. Any
> suggestions?
> SQL 2000, sp4
> Thanks,
> Steve
>|||Make sure that the database is NOT selected in EM. I've had the exact same
problem and when I selected a different db in EM (master for instance) and
re-ran the restore from Query Analyzer it worked fine.
"Steve Deering" wrote:

> While attempting to restore a db, I get the following error message:
> "RESTORE DATABASE is terminating abnormally.
> Exclusive access could not be obtained because the database is in use."
> But looking at Current Activity in EM, I see nothing logged into the
> database. The database I am restoring to is set to Single-User. Any
> suggestions?
> SQL 2000, sp4
> Thanks,
> Steve
>|||If you are married to using the SQLEM, then here is a trick I often use:
1. Right-click the database.
2. Detach the database. If there are users currently connected, then select
to disconnect them all without notifying them. When it is done, cancel so
you don't actually detach the database.
3. Now, right-click again and set Offline.
Now, you should be able to restore the database without any problems. Yes,
you can restore a database if it is marked offline.
Sometimes, however, you can not click fast enough to set it offline before
another user logs in. You can try this procedures a few time, but at some
point, you are just going to be stuck with script.
I usually use the same syntax as everyone else has shown you, but I like to
set the database offline instead of single-user.
Regardless, before SQL Server 2000, there was no other way to disconnect
users other than scripting out multiple KILL commands to get rid of all the
connections.
Sincerely,
Anthony Thomas
"Steve Deering" <Steve@.vin.com> wrote in message
news:1118060114.644682.280310@.g43g2000cwa.googlegroups.com...
While attempting to restore a db, I get the following error message:
"RESTORE DATABASE is terminating abnormally.
Exclusive access could not be obtained because the database is in use."
But looking at Current Activity in EM, I see nothing logged into the
database. The database I am restoring to is set to Single-User. Any
suggestions?
SQL 2000, sp4
Thanks,
Steve

No comments:

Post a Comment