38 C
Dubai
Monday, August 8, 2022
spot_img

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
Specialized in Microsoft Azure - Office 365 / Microsoft Exchange; conducted numerous projects worldwide in designing, supporting, and implementing messaging and virtualization infrastructure for medium-sized and large enterprises. Further, I am a Cloud Architect and Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here