This SQL Server tutorial explains how to use the SQL Server DROP LOGIN statement with syntax and examples.
Description
The DROP LOGIN statements is used to remove an identity (ie: Login) used to connect to a SQL Server instance.
Syntax
The syntax for the DROP LOGIN statements in SQL Server (Transact-SQL) is:
DROP LOGIN login_name;
Parameters or Arguments
user_nameThe 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 statements in SQL Server (Transact_SQL).
For example:
DROP LOGIN adglob;
This DROP LOGIN example would drop the Login called adglob. This DROP LOGIN statement will only run if adglob is not currently logged in. If adglob is currently logged into SQL Server, the DROP LOGIN statements will raise an error.