I want to rename a database, but keep getting the error that 'couldn't get exclusive lock' on the database, which implies there is some connection(s) still active.
How can I kill all the connections to the database so that I can rename it?
I want to rename a database, but keep getting the error that 'couldn't get exclusive lock' on the database, which implies there is some connection(s) still active.
How can I kill all the connections to the database so that I can rename it?
Right click on the database name, click on Property to get property window, Open the Options tab and change the "Restrict Access" property from Multi User to Single User. When you hit on OK button, it will prompt you to closes all open connection, select "Yes" and you are set to rename the database....
I've always used:
I use sp_who to get list of all process in database. This is better because you may want to review which process to kill.
Result
You can use command in KillCommand column to kill the process you want to.
use the 'master' database and run this query, it will kill all the active connections from your database.
You can Use SP_Who command and kill all process that use your database and then rename your database.