I have created the user sagar
in SQL Server 2012 database and mapped it to the XYZ
database. After some time I deleted the XYZ
database and now I don't need the existing user sagar
also. But when I try to delete the user from SQL Srever Management Studio. I am getting the following exception
Could not drop login 'sagar' as the user is currently logged in. error:15434
Microsoft SQL Server Error 15434 This error generates when a login has made a connection to the SQL Server Instance and you are trying to drop the same login. Solution to fix this issue is to close all sessions which are opened by this login and then drop it.
If you are using SQL Server Management Studio you can browse to the user and right-click selecting delete.
User can be deleted after killing the session by identifying the session_id of the user.
SELECT session_id FROM sys.dm_exec_sessions WHERE login_name = 'sagar' KILL 51 --51 is session_id here, you may get different id
Now you can delete the login simply by executing the below query (or) by using sql server management studio options.
DROP LOGIN 'sagar'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With