Sql Server Drop Login Statement

SQL Server: DROP LOGIN statement

In this post 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 AODBA;

This DROP LOGIN example would drop the Login called AODBA. This DROP LOGIN statement will only run if AODBA is not currently logged in. If AODBA is currently logged into SQL Server, the DROP LOGIN statement will raise an error.