[SQL] Could not drop login as the user is currently logged in.

You are getting below error message while performing the SAP system copy in the Microsoft SQL Server database environment.

Errors when executing sql command: 
[Microsoft][ODBC Driver 17 for SQL Server]
[SQL Server]Could not drop login 'USER_ABC' as the user 
is currently logged in.

Solution

Firstly, you have to find the session ID with the user (example, USER_ABC).

select session_id from sys.dm_exec_sessions where login_name = 'USER_ABC'

Use the session ID from above output and kill the user session. (example, 88 is the session number)

kill 88

Finally, you can drop the user. (example, USER_ABC).

drop login USER_ABC

If the drop is not possible due to logged user, please try with another user and perform the drop command again.

You May Also Like

1 Comment

Leave a Reply?