Re: Programmatically Dropping databases

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: KB (a_at_b.com)
Date: 12/06/04


Date: Mon, 6 Dec 2004 14:19:56 -0500

you have to kill all user processes that are currently connected to your db
use sp_who to list all the connections and use the KILL command with SPID
from sp_who as a parameter to kick them out

"Jon Pope" <jon.pope@healthlinkinc.com> wrote in message
news:O5b%23XY82EHA.3380@TK2MSFTNGP09.phx.gbl...
> I'm trying to drop a SQL2K database through SQL. I'm using the following
> command:
>
> USE Master DROP DATABASE '<DB Name>'
>
>
> However, when I attempt to do this, I get the following error:
>
> Error: Cannot drop the database '<DB Name>' because it is currently in
use.
>
> How can I drop a database when a user is logged into it? Is there a way I
> can programmatically kick people off the database so I can then drop that
> database?
>
>
> Cheers, Jon
>
>



Relevant Pages

  • Re: How can I open an SQL database and be the only one who has access to it?
    ... you can determine how SS permits access to your server. ... SINGLE_USER allows one user at a time to connect to the database. ... controlled by the termination clause of the ALTER DATABASE statement. ... To allow multiple connections, the database must be changed to ...
    (microsoft.public.data.ado)
  • Re: ORA-12518, 04030 errors after 9i-10G upgrade.
    ... All went ok until users started connecting in 100+ numbers, database is ... set up for dedicated server connections, this was never a problem in 9i. ... This did not solve problems so bounced database and decreased SGA to ... out of process memory errors. ...
    (comp.databases.oracle.server)
  • Re: ORA-12518, 04030 errors after 9i-10G upgrade.
    ... All went ok until users started connecting in 100+ numbers, database is ... set up for dedicated server connections, this was never a problem in 9i. ... out of process memory errors. ... that Oracle is having issues with OS resources. ...
    (comp.databases.oracle.server)
  • Re: ORA-12518, 04030 errors after 9i-10G upgrade.
    ... New server has 6GB ram. ... All went ok until users started connecting in 100+ numbers, database is ... set up for dedicated server connections, this was never a problem in 9i. ... This did not solve problems so bounced database and decreased SGA to ...
    (comp.databases.oracle.server)
  • Re: Proper Database Connection Cleanup
    ... but I think two of them have a database query in them. ... Public Sub ConnectToDB2(byref XCmd, byref YRS, byRef Conn) ... Set ObjRS = ObjCmd.Execute ... from DB connections in my code or from something else? ...
    (microsoft.public.scripting.vbscript)