How to delete database, error 5030 database can't be locked

后端 未结 8 1382
自闭症患者
自闭症患者 2021-02-15 00:50

I am trying to delete an existing database in SQL Server 2005. My first attempt produced the following error:

5030: The database could not be exclusively

相关标签:
8条回答
  • 2021-02-15 01:36

    Why would we make a deleted DB to multi user mode.

    ALTER DATABASE dbName SET MULTI_USER WITH ROLLBACK IMMEDIATE
    
    0 讨论(0)
  • 2021-02-15 01:39

    I hate to say it, but a quick solution is to restart the system, make sure the sql server server service is not started, then you should be able to delete.

    Also, is IIS stopped if you db is connected to a web ap?

    0 讨论(0)
  • 2021-02-15 01:41

    You don't happen to know if anyone left a transaction in an uncompleted rollback state (or otherwise uncompleted)? Might as well check the locks list, too.

    0 讨论(0)
  • 2021-02-15 01:42

    No One else should be using the DB, including yourself.

    0 讨论(0)
  • 2021-02-15 01:44

    In the management studio, goto Management->Activity Monitor (right click) -> View Processes. That will give you a full list of everything running, you can sort the list by Database to see what is still attached, and you can also kill any connections. It's easy to end up with orphaned connections that will prevent you from getting the exclusive access that you need.

    0 讨论(0)
  • 2021-02-15 01:44

    This error normally occurs when your database is in Multi User mode where users are accessing your database or some objects are referring to your database. First you should set the database to single user mode:

    ALTER DATABASE dbName
    SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    

    Now we will try to delete the database

    delete DATABASE ...
    

    Finally set the database to Multiuser mode

    ALTER DATABASE dbName
    SET MULTI_USER WITH ROLLBACK IMMEDIATE
    
    0 讨论(0)
提交回复
热议问题