Tuesday, June 28, 2011

MSSQL - Disconnect all users from a database

ALTER DATABASE databaseName SET multi_USER WITH ROLLBACK IMMEDIATE

2 comments:

  1. Doesn't work, says error in syntax near 'WITH'

    ReplyDelete
  2. yeah.. i noticed that too.. this happens to me but to my own connections (using Management Studio).. so what I normally do is

    1. execute sp_who
    2. then find the spid with the database you want to disconnect the users
    3. then execute "kill ".. for instance.. kill 666

    :)

    ReplyDelete