Friday, March 9, 2012

Drop Database

I want to drop a database but there are still users online from several
computers.
Is there any way of deleting it?You can kill the Processes of the users associated with the database within
a Cursor.
Information about Running processes are present within the Proc sp_who.
Processes can be killed with KILL Number.
Drop the table afterwards the killing.
HTH, Jens Smeyer.
http://www.sqlserver2005.de
--
"Joaquim Meireles" <jmeireles@.lognet.pt> schrieb im Newsbeitrag
news:O33JqyAQFHA.3544@.TK2MSFTNGP12.phx.gbl...
>I want to drop a database but there are still users online from several
>computers.
> Is there any way of deleting it?
>|||Use the ALTER DATABASE command to set the database to single user, restricte
d user or off line. Also
use the ROLLBACK option to kick out current users. ALTER DATABASE is documen
ted in Books Online.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Joaquim Meireles" <jmeireles@.lognet.pt> wrote in message
news:O33JqyAQFHA.3544@.TK2MSFTNGP12.phx.gbl...
>I want to drop a database but there are still users online from several com
puters.
> Is there any way of deleting it?
>|||You can set the database to SINGLE_USER mode with the ROLLBACK option to
forcibly kill existing users:
ALTER DATABASE MyDatabase
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
DROP DATABASE MyDatabase
GO
Hope this helps.
Dan Guzman
SQL Server MVP
"Joaquim Meireles" <jmeireles@.lognet.pt> wrote in message
news:O33JqyAQFHA.3544@.TK2MSFTNGP12.phx.gbl...
>I want to drop a database but there are still users online from several
>computers.
> Is there any way of deleting it?
>

No comments:

Post a Comment