DEV Community

taijidude
taijidude

Posted on

3 3

Get rid of an MS SQL Server database in SingleUserMode

Yesterday i while trying to run some tests against a database with a copy of our production data the program i was working on was crashing with strange errors. When trying to connect to the database via sql server management studio i was greeted with all kinds of errors. "The database is in single user mode, no connection allowed" and so on... Looked for every possible app that was connected to this database and deactivated it. Waited for the nightly restart of the database server. Still not possible to connect.

While googling i today i found the stored procedure sp_who2 which lists you all the active connections to you databases.

With the command kill you are able to terminate the connection.

Example:

sp_who2
Kill 51

Enter fullscreen mode Exit fullscreen mode

After this i was able to connect again, delete and restore the database. I'm a bit short on time thats why i'm not investigating any further. But if this comes up again i will dig deeper.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more