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

后端 未结 8 1404
自闭症患者
自闭症患者 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: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
    

提交回复
热议问题