Dropping a login from a master db of a Synapse serverless SQL pool

pmscorca 987 Reputation points
2024-08-25T17:29:44.3+00:00

Hi,

I need to drop my login from a master database of a Synapse serveless SQL pool avoiding "Could not drop login 'xxxx@yyyy.com' as the user is currently logged in" error.

My login is a Microsoft Entra user and I'm using SSMS to drop my login.

My Microsoft Entra user is a Synapse Administrator for the Synapse workspace.

Any suggests to me, please? Thanks

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,847 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnnuKumari-MSFT 32,736 Reputation points Microsoft Employee
    2024-08-27T06:23:16.8533333+00:00

    Hi @pmscorca ,

    Thankyou for using Microsoft Q&A platform and thanks for posting your query here.

    I understand that while trying to drop Login , you are facing this error: "Could not drop login 'xxxx@yyyy.com' as the user is currently logged in".

    Kindly try to Terminate All Sessions for the Login before dropping the login.

    • First, you need to terminate any active sessions for the login you wish to drop. You can use the following SQL command to kill all sessions for that login:
    -- Replace 'xxxx@yyyy.com' with your actual login name
    DECLARE @kill varchar(max) = '';
    SELECT @kill = @kill + 'KILL ' + CONVERT(varchar(5), session_id) + ';'
    FROM sys.dm_exec_sessions
    WHERE login_name = 'xxxx@yyyy.com';
    EXEC(@kill);
    
    • Post that, drop the login: DROP LOGIN [xxxx@yyyy.com]; Hope it helps. Kindly accept the answer by clicking on Accept answerbutton. Thankyou
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Erland Sommarskog 109.9K Reputation points MVP
    2024-08-25T18:19:51.1866667+00:00

    DROP LOGIN sounds like a good command. But obviously, you need be logged in with a different login than the one you are trying to drop. And you need to make sure that the login you are trying to drop is not connected.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.