Fix Error: Could not drop login ‘test’ as the user is Currently logged in( Microsoft SQL Server , Error:15434)

Posted on Updated on

Fix Error: Could not drop login ‘test’ as the user is Currently logged in( Microsoft SQL Server , Error:15434)

 Recently I have created a test Login on UAT server to test some cases.

When I ran the script to drop the Login.

DROP LOGIN test

GO

It has given bellow error.

Msg 15434, Level 16, State 1, Line 1
Could not drop login ‘test’ as the user is currently logged in.

First of all, I have closed all the connections from SSMS there was no connection open.

And Finally I come with solution to kill all connection of test user, I ran below script to kill all open connection of ‘test’ user.

Here is the script.

SELECT session_id

FROM sys.dm_exec_sessions

WHERE login_name = ‘test

And killed all active connection

Kill 51

GO

Kill 55

Replace 51, 52 with your session_id.

DROP LOGIN test

And finally it is dropped.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s