Solve the problem that a database cannot be deleted

Source: Internet
Author: User

When I sorted out the test environment, I encountered a problem where the database could not be deleted.

 

The following error is reported:

Alter failed for Database 'fastsearchadmindatabase'. (Microsoft. SqlServer. Smo)

------------------------------

Additional information:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft. SqlServer. ConnectionInfo)

------------------------------

Changes to the state or options of database 'fastsearchadmindatabase' can not be made at this time. The database is in single-user mode, and a user is currently connected to it.

Alter database statement failed. (Microsoft SQL Server, Error: 5064)

 

 

Solution

======================================

Run the following SQL query statement to obtain the DBID of the problematic database.

select db_id('FASTSearchAdminDatabase')

Queries the session currently connected to the database.

select * from sys.sysprocesses where dbid = 30

Kill it

kill 54

Then we can connect to the database to modify the single user mode to multiuser mode.

alter database [FASTSearchAdminDatabase] set multi_user

 

Okay, the database can be deleted.

 

Update

This time I tried to Restore the SSP DB, and the result was always reported that other users are using this DB, so they could not Restore the DB.

After the above method is used, a new session is generated after the session is killed.

The solution is very simple. The network that constantly tries to connect to this SQL is disconnected and restored successfully.

Remember to restore the disconnected network.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.