SQL Server: DROP LOGIN statement
This SQL Server tutorial explains how to use the SQL Server DROP LOGIN statement with syntax and examples.
The DROP LOGIN statement is used to remove an identity (ie: Login) used to connect to a SQL Server instance.
The syntax for the DROP LOGIN statement in SQL Server (Transact-SQL) is:
DROP LOGIN login_name;
Parameters or Arguments
- The name of the Login to remove.
- You can not drop a Login when it is currently logged into SQL Server.
- If you drop a Login that has database users mapped to it, the users will be orphaned in SQL Server.
- See also the CREATE LOGIN statement and the ALTER LOGIN statement.
Let’s look at an example that shows how to use the DROP LOGIN statement in SQL Server (Transact_SQL).
DROP LOGIN techonthenet;
This DROP LOGIN example would drop the Login called techonthenet. This DROP LOGIN statement will only run if techonthenet is not currently logged in. If techonthenet is currently logged into SQL Server, the DROP LOGIN statement will raise an error.