|
Posted by Hugo Kornelis on 05/29/06 00:27
On 27 May 2006 19:48:27 -0700, coosa wrote:
>How do i close a current connection to a database using t-sql?
>I fail some time to drop the database getting messages that it's
>currently in use.
Hi coosa,
If you want to disconnect YOUR OWN connection to a database, check out
Erland's reply.
If you need to do maintenance but can't because OTHER people still have
open connections to a database, then you might want to use one of the
following
ALTER DATABASE <dbname> SET SINGLE_USER
or
ALTER DATABASE <dbname> SET SINGLE_USER WITH ROLLBACK_IMMEDIATE
The first version will allow curent connection to finish their business
and commit their work. The latter option immediately disconnects all
open conenctions and rolls back any changes from unfinished
transactions.
--
Hugo Kornelis, SQL Server MVP
Navigation:
[Reply to this message]
|