SQL Server: DROP LOGIN statement
This SQL Server tutorial explains how to use the SQL Server DROP LOGIN statement with syntax and examples.
Description
The DROP LOGIN statement is used to remove an identity (ie: Login) used to connect to a SQL Server instance.
Syntax
The syntax for the DROP LOGIN statement in SQL Server (Transact-SQL) is:
DROP LOGIN login_name;
Parameters or Arguments
- user_name
- The name of the Login to remove.
Note
- 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.
Example
Let’s look at an example that shows how to use the DROP LOGIN statement in SQL Server (Transact_SQL).
For example:
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.