DROP USER (Transact-SQL)

Removes a user from the current database.

Syntax

DROP USER [ user ]
[ ; ]

Description

The DROP USER statement removes a user from the current database. A user is a database-level identity that is used to connect to an instance of SQL Server. Users are mapped to server-level principals (logins).

You can drop a user only if it does not have any of the following:

If the user owns any objects in the database, you must first transfer ownership of those objects to another user or drop the objects before you can drop the user.

Note: If the user that you are trying to drop is the owner of any objects in the database, the DROP USER statement will fail. You must first transfer ownership of the objects to another user or drop the objects before you can drop the user.

Arguments

Argument Description
user Specifies the name of the user to be dropped. user must be a valid identifier.

Permissions

To execute DROP USER, the user must be logged in as a member of the db_owner or db_securityadmin fixed database roles, or have the ALTER ANY USER permission.

Examples

A. Dropping a user

The following example drops the user named Janeth from the current database.

USE AdventureWorks2012;
GO
DROP USER Janeth;
GO
Tip: Always specify the database context using the USE statement before executing DROP USER to ensure you are operating on the correct database.

See Also