Knowledge found and lost while working with Microsoft Dynamics CRM
RSS icon Home icon
  • Quickly Disconnecting SQL Users from a Database

    Posted on April 3rd, 2006 mitch Print Print 2 comments

    On SQLServerCentral.com tonight, I found a really neat little SQL procedure written by Brian Knight that allows you to disconnect any users currently connected to a specific database.

    Quickly Disconnect Users

    I needed this script so I could disconnect all of the CRM users so I could perform some maintenance on the CRM databases.
     

    Development, Dynamics CRM
    1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
    Loading ... Loading ...
    3,797 views
     

    2 responses to “Quickly Disconnecting SQL Users from a Database”

    1. The following command will disconnect all users and make sure that users cannot logon while you are making your changes…

      ALTER DATABASE dbName SET SINGLE_USER WITH ROLLBACK IMMEDIATE

      You can allow access again with the MULTI_USER option

    2. Excellent suggestion! Thanks Darrel.

    Leave a reply