Skip to content

Latest commit

 

History

History
77 lines (61 loc) · 2.81 KB

File metadata and controls

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

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.

Note

[!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)