Cannot use KILL to kill your own process

Meh*_*aki 1 sql sql-server ssms

I have SQL Server database which I want to delete using

DROP DATABASE <database-Name>
Run Code Online (Sandbox Code Playgroud)

But I receive this error:

Cannot drop database "Database-Name" because it is currently in use.

To solve the issue I called sp_who so I can see spid of the database which is in use.

Then I tried to kill it using :

KILL <spid>
Run Code Online (Sandbox Code Playgroud)

But I see this error: Cannot use KILL to kill your own process. I use SQL SERVER Management Studio to run the commands.

sti*_*bit 5

您不能终止自己的会话,也不能删除正在使用的数据库。由于整个故事告诉您尝试删除会话当前使用的数据库,因此您可以更改会话使用的数据库,然后删除数据库。

USE master; -- or any other database not named <database name>
DROP DATABASE <database name>;
Run Code Online (Sandbox Code Playgroud)