How to gain exclusive access to SQL Server 2005 database to restore?

后端 未结 7 1842
礼貌的吻别
礼貌的吻别 2021-01-31 05:21

Whenever I restore a backup of my database in SQL Server I am presented with the following error:

Msg 3101, Level 16, State 1, Line 1
Exclusive access could not          


        
7条回答
  •  隐瞒了意图╮
    2021-01-31 05:46

    So far this worked for me. I right clicked on the database > Tasks > Detach...

    This brought up a screen that allows you to view all active connections. You can then go through and disconnect each connection. When you hit ok you've detached the database and need to Attach the database. Right-click on Databases and choose attach, pick you mdf file and the db is attached. At this point you should have exclusive access to restore.

    Note: I tested this by connecting to one of his databases from my local machine and from the server dropped the connections to my database and I didn't lose my connection to his database.

提交回复
热议问题