June 1, 2010 at 9:59 am
Due to migration to a new server, I need to disconnect all users. I can run ALTER DATABASE <db_name> SET SINGLE_USER WITH ROLLBACK IMMEDIATE in a loop against all databases, but is there a better method for this so I don't need to write a script?
Thanks
June 1, 2010 at 10:24 am
Better method... Not really.
Simplier (and not recommended) methods? Yes.
1) Set all DBs to Single User mode.
2) Take all DBs offline (will have to click the "Disconnect connected users" option)
3) Stop the services.
Best method is to write your script to kill the users, then set the DBs to Single User or Offline right after each database has been killed to prevent them from logging back in.
If you use Terminal Services or Citrix, you could kill the connections from there, but that doesn't necessarily get all users attached to the database as some could be connecting directly in.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy