Drop Database with Open Connections

  • How can I drop a database and force any open connections to close (just like I would when executing the Drop Database Dialogue in SQL Management Studio with the Close Connections Checkbox checked).  Suppose I don't want to do the combination sp_who and Kill Spid thing.
     
    I ran a Trace to see what Management Studio does prior to the Drop Database (with Close Connections checked) and was not able to find the commands (e.g. Kill) it uses to close the connections.
     
    ALTERING the database and putting it into Single_user Mode with Rollback Immediate I still get the Open Connections message when I attempt the Drop.
     
    How do I close all the other open connections for a database?
     
    Thanks
     
    ...Ray
  • loop thru all the sysprocesses for your db_id and kill them, except dont kill your own process,

    and then check if there are any new processes to be killed if u feel like it, and then u are done. now the database can be dropped

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply