Drop login in SQL Server

The DROP LOGIN statement could be used to delete an user or login that used to connect to a SQL Server instance.

Syntax –

DROP LOGIN loginname;
GO 

Permissions :
The user which is deleting the login must have ALTER ANY LOGIN permission on the server.

Note –
A login which is currently logged into SQL Server cannot be dropped.

If you try to drop login which is currently using SQL Server, the DROP LOGIN statement will raise below error.



Drop failed for Login “loginname”

Let us assume, we have created below login:

CREATE LOGIN geeks  
WITH PASSWORD = ‘gEe@kF0rG##ks’; 

Below example shows how to use DROP LOGIN statement in SQL Server.

Example –

DROP LOGIN geeks; 

DROP LOGIN used in above example would delete the login called geeks from SQL server. This DROP LOGIN statement will only run if geeks is not the current user.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.