The DROP LOGIN statement could be used to delete an user or login that used to connect to a SQL Server instance.
DROP LOGIN loginname; GO
The user which is deleting the login must have ALTER ANY LOGIN permission on the server.
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.
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.
- Create login in SQL Server
- Alter login in SQL Server
- Create, Alter and Drop schema in MS SQL Server
- DROP SCHEMA in SQL Server
- Authentication Bypass using SQL Injection on Login Page
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- SQL | DROP, TRUNCATE
- SQL | ALTER (ADD, DROP, MODIFY)
- Difference between DELETE and DROP in SQL
- Difference between DROP and TRUNCATE in SQL
- CREATE and DROP INDEX Statement in SQL
- Delete statement in MS SQL Server
- SQL Server Mathematical functions (SQRT, PI, SQUARE, ROUND, CEILING & FLOOR)
- SQL Server Identity
- SQL SERVER | Conditional Statements
- SQL Server | STUFF() Function
- SQL Server | SERVERPROPERTY()
- Mean and Mode in SQL Server
- Allow only alphabets in column in SQL Server
- SQL SERVER | IN Condition
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.