Sunday, February 19, 2012

How to bring down a database

I have a need to shutdown a database on a server.
But it has other databases, I want to leave other
databases up and running.
How can I bring down a database and then how can
I bring it back up without affecting other databases
on the same server.
Thank you,
-LeOne way would be put the db in single user mode, then detach the db, and
then reattach it.
Quentin
"Linda" <anonymous@.discussions.microsoft.com> wrote in message
news:2a00201c46536$90a1aad0$a301280a@.phx
.gbl...
> I have a need to shutdown a database on a server.
> But it has other databases, I want to leave other
> databases up and running.
> How can I bring down a database and then how can
> I bring it back up without affecting other databases
> on the same server.
> Thank you,
> -Le|||Assuming you have already logged out or killed all user processes you can
take the DB offline as follows:
EXEC sp_dboption 'DATABASE_NAME', 'offline', 'TRUE'
Perhaps more useful is to make the database single-user only:
USE DATABASE_NAME
EXEC sp_dboption 'DATABASE_NAME', 'single user', 'TRUE'
David Portas
SQL Server MVP
--|||Hi,
To make a database Offline:-
alter database <dbname> set single_user with rollback immediate -- turns
database to single user
go
alter database <dbname> set offline
-- To set database online and multi user
alter database <dbname> set online
go
alter database <dbname> set multi_user
go
THanks
Hari
MCDBA
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:oZ-dncVuSMhJW3DdRVn-uw@.giganews.com...
> Assuming you have already logged out or killed all user processes you can
> take the DB offline as follows:
> EXEC sp_dboption 'DATABASE_NAME', 'offline', 'TRUE'
> Perhaps more useful is to make the database single-user only:
> USE DATABASE_NAME
> EXEC sp_dboption 'DATABASE_NAME', 'single user', 'TRUE'
> --
> David Portas
> SQL Server MVP
> --
>|||David,
Thank you,
-Le
>--Original Message--
>Assuming you have already logged out or killed all user
processes you can
>take the DB offline as follows:
>EXEC sp_dboption 'DATABASE_NAME', 'offline', 'TRUE'
>Perhaps more useful is to make the database single-user
only:
>USE DATABASE_NAME
>EXEC sp_dboption 'DATABASE_NAME', 'single user', 'TRUE'
>--
>David Portas
>SQL Server MVP
>--
>
>.
>|||Hari,
Thank you,
-Le

>--Original Message--
>Hi,
>To make a database Offline:-
>alter database <dbname> set single_user with rollback
immediate -- turns
>database to single user
>go
>alter database <dbname> set offline
>
>-- To set database online and multi user
>alter database <dbname> set online
>go
>alter database <dbname> set multi_user
>go
>THanks
>Hari
>MCDBA
>
>
>"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org>
wrote in message
>news:oZ-dncVuSMhJW3DdRVn-uw@.giganews.com...
user processes you can[vbcol=seagreen]
user only:[vbcol=seagreen]
>
>.
>|||Quentin,
Thank you,
-Le

>--Original Message--
>One way would be put the db in single user mode, then
detach the db, and
>then reattach it.
>Quentin
>
>"Linda" <anonymous@.discussions.microsoft.com> wrote in
message
> news:2a00201c46536$90a1aad0$a301280a@.phx
.gbl...
>
>.
>

No comments:

Post a Comment