30 C
Dubai
Thursday, November 28, 2024

Could not drop Login as the user is currently logged in. Error 15434

Created a Temporary users for testing purposes . But not able to remove the user in Microsoft SQL server Management Studio.

Error :

Could not drop Login as the user is currently logged in. (Microsoft SQL server,Error: 15434)

image

Drop Failed for Login (Microsoft.Sqlserver.smo)

Additional Information:

An exception while executing a Transact-SQL statement or batch.

(Microsoft.Sqlserver.Connectioninfo)

 

Solution –

Step 1 – Get the session ID (ENTER Login name in below)


SELECT session_id

FROM sys.dm_exec_sessions

WHERE login_name = 'Enter the login name you are trying to remove'

Step 2 – Enter the session ID like below to kill the existing sessions (Mine is 323)


SELECT session_id

FROM sys.dm_exec_sessions

WHERE login_name = 'Enter the login name you are trying to remove'

KILL 323

Step 3 – Remove User

Now you should be able to remove the user.

Good to know-

To Take Database Offline Immediately. Killing all existing connections.


USE master
GO
ALTER DATABASE databasename
SET OFFLINE WITH ROLLBACK IMMEDIATE
GO

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?