SQL server error 15434 arises while removing a SQL Server login. This error generates when we try to drop a login that has an active open connection to SQL Server Instance.
Here at Bobcares, we have seen several such SQL related issues as part of our Server Management Services for web hosts and online service providers.
Today we’ll take a look at the cause for this error and how to fix it.
What causes SQL server error 15434 to occur
Before we get into the solution part, let’s first see what causes this error to occur.
SQL server error 15434 occurs when a login has made a connection to the SQL Server Instance and we are trying to drop the same login.
For instance, here is an image of the error message.
Here is an error message received by one of our customers
Drop failed for Login “domain\abc”
Could not drop login ‘domain\abc’ as the user is currently logged in. (Microsoft SQL Server, Error: 15434)
In this error message, it is clear that the above login is currently logged in. Next, we shall see how our Support Engineers tackle this error.
How we fix SQL server error 15434
Now, let’s see how we fix this error for our customers.
Initially, we run the below T-SQL code to get the details about the sessions or connections that this login has made to the SQL Server Instance.
SELECT login_name, * FROM sys.dm_exec_sessions
WHERE login_name = ‘domain\abc’
Go
As a result of the above T-SQL code, it will display the details for this login along with the session id.
To solve this error we close all sessions which are opened by this login and then drop it.
For that, we kill this session.
We make sure to check the SQL code running behind the session id. If it is not critical go ahead and drop the login. In case, if any DML or other operations are running about which you are not aware of, do contact application owners to get the details about this session id. Don’t kill any session-id that you are not aware of. Now go ahead and kill the above session which is running using the login id.
Kill <session_id>
GO
Here, replace session_id with the value.
After the command executed successfully next is to go ahead and drop the login again. This time the login will be dropped successfully.
If the same error repeats while dropping the login then check SQL Server services log on accounts. Sometimes if you run SQL Server services using the account which you want to drop throws the same error. If this is the case then change the logon account to some other domain account to release this log in.
Change the logon account of all SQL Server services if they are running using this account. After the changes is made to the services, restart the SQL Server service to bring a new account in use by SQL Server.
After this, drop the account again. This time the login will be removed successfully.
[Need any further assistance in fixing SQL errors? – We’re available 24*7]
Conclusion
In short, this error occurs when we try to drop a login that has an active open connection to the SQL Server Instance. Today, we saw the resolution to this SQL error.
0 Comments