Monday, March 12, 2012

Problem with restoring sql server database

Hi
I need to restore a recent backup of sql server database. However, the
message I am getting is that database needs to be in exclusive mode. It is in
use. My question is how to know who is using the database and get them off
the database so that I can restore the database from a backup. Thanks in
advanceHave a look at the ALTER DATABASE command and the SET SINGLE_USER and
ROLLBACK IMEDIATE options.
--
Andrew J. Kelly SQL MVP
Solid Quality Mentors
"Jack" <Jack@.discussions.microsoft.com> wrote in message
news:C581FA7C-EC5A-4A97-AB02-790554E8ABB2@.microsoft.com...
> Hi
> I need to restore a recent backup of sql server database. However, the
> message I am getting is that database needs to be in exclusive mode. It is
> in
> use. My question is how to know who is using the database and get them off
> the database so that I can restore the database from a backup. Thanks in
> advance|||Thanks for your help Andrew. I appreciate it. Let me try this and see.
"Andrew J. Kelly" wrote:
> Have a look at the ALTER DATABASE command and the SET SINGLE_USER and
> ROLLBACK IMEDIATE options.
> --
> Andrew J. Kelly SQL MVP
> Solid Quality Mentors
>
> "Jack" <Jack@.discussions.microsoft.com> wrote in message
> news:C581FA7C-EC5A-4A97-AB02-790554E8ABB2@.microsoft.com...
> > Hi
> > I need to restore a recent backup of sql server database. However, the
> > message I am getting is that database needs to be in exclusive mode. It is
> > in
> > use. My question is how to know who is using the database and get them off
> > the database so that I can restore the database from a backup. Thanks in
> > advance
>|||Most of the time, it's "you," the DBA trying to restore the database that is
using the database. Whether using Enterprise Manager or Management Studio,
users tend to select the database in the UI when restoring. This has
already created a connection to the database. I'd rather do it using scripts
"Jack" <Jack@.discussions.microsoft.com> wrote in message
news:CEF6E906-04B9-4053-9E83-5CB7E89C78CD@.microsoft.com...
> Thanks for your help Andrew. I appreciate it. Let me try this and see.
> "Andrew J. Kelly" wrote:
>> Have a look at the ALTER DATABASE command and the SET SINGLE_USER and
>> ROLLBACK IMEDIATE options.
>> --
>> Andrew J. Kelly SQL MVP
>> Solid Quality Mentors
>>
>> "Jack" <Jack@.discussions.microsoft.com> wrote in message
>> news:C581FA7C-EC5A-4A97-AB02-790554E8ABB2@.microsoft.com...
>> > Hi
>> > I need to restore a recent backup of sql server database. However, the
>> > message I am getting is that database needs to be in exclusive mode. It
>> > is
>> > in
>> > use. My question is how to know who is using the database and get them
>> > off
>> > the database so that I can restore the database from a backup. Thanks
>> > in
>> > advance
>>|||Jack wrote:
> Hi
> I need to restore a recent backup of sql server database. However,
> the message I am getting is that database needs to be in exclusive
> mode. It is in use. My question is how to know who is using the
> database and get them off the database so that I can restore the
> database from a backup. Thanks in advance
Hi, Jack
You can use sp_who2 or look in Management / Activity Monitor (in
Management Studio).
It is possible that the connection using the database belongs to
yourself. Close any open windows that are accesing that database. If
you are using a query window to restore, make sure you the current
database is not that database (change it to master, for example).
--
Razvan Socol
SQL Server MVP

No comments:

Post a Comment