Skip to content

Latest commit

 

History

History
77 lines (61 loc) · 2.81 KB

drop-user-transact-sql.md

File metadata and controls

77 lines (61 loc) · 2.81 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic ms.custom f1_keywords helpviewer_keywords dev_langs monikerRange
DROP USER (Transact-SQL)
DROP USER (Transact-SQL)
VanMSFT
vanto
05/12/2017
sql
t-sql
reference
ignite-2024
DROP_USER_TSQL
DROP USER
dropping users
DROP USER statement
deleting users
database user removal [SQL Server]
removing users
users [SQL Server], removing
TSQL
>=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric

DROP USER (Transact-SQL)

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics PDW FabricSQLDB]

Removes a user from the current database.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

-- Syntax for SQL Server and Azure SQL Database  
  
DROP USER [ IF EXISTS ] user_name  
-- Syntax for Azure Synapse Analytics and Parallel Data Warehouse  
  
DROP USER user_name  

Arguments

IF EXISTS
Applies to: [!INCLUDEssNoVersion] ( [!INCLUDEsssql16-md] through current version, [!INCLUDEsssds]).

Conditionally drops the user only if it already exists.

user_name
Specifies the name by which the user is identified inside this database.

Remarks

Users that own securables cannot be dropped from the database. Before dropping a database user that owns securables, you must first drop or transfer ownership of those securables.

The guest user cannot be dropped, but guest user can be disabled by revoking its CONNECT permission by executing REVOKE CONNECT FROM GUEST within any database other than master or tempdb.

Caution

[!INCLUDEssCautionUserSchema]

Permissions

Requires ALTER ANY USER permission on the database.

Examples

The following example removes database user AbolrousHazem from the [!INCLUDE sssampledbobject-md] database.

DROP USER AbolrousHazem;  
GO  

See Also

CREATE USER (Transact-SQL)
ALTER USER (Transact-SQL)
EVENTDATA (Transact-SQL)