Skip to content

Latest commit

 

History

History
79 lines (55 loc) · 2.76 KB

sp-droprole-transact-sql.md

File metadata and controls

79 lines (55 loc) · 2.76 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
sp_droprole (Transact-SQL)
sp_droprole removes a database role from the current database.
markingmyname
maghan
randolphwest
11/28/2023
sql
system-objects
reference
sp_droprole
sp_droprole_TSQL
sp_droprole
TSQL

sp_droprole (Transact-SQL)

[!INCLUDE SQL Server]

Removes a database role from the current database.

Important

In [!INCLUDE ssVersion2005], sp_droprole was replaced by the DROP ROLE statement. sp_droprole is included only for compatibility with earlier versions of [!INCLUDE ssNoVersion] and might not be supported in a future release.

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

Syntax

sp_droprole [ @rolename = ] N'rolename'
[ ; ]

Arguments

[ @rolename = ] N'rolename'

The name of the database role to remove from the current database. @rolename is sysname, with no default. @rolename must already exist in the current database.

Return code values

0 (success) or 1 (failure).

Remarks

Only database roles can be removed by using sp_droprole.

A database role with existing members can't be removed. All members of a database role must be removed before the database role can be removed. To remove users from a role, use sp_droprolemember. If any users are still members of the role, sp_droprole displays those members.

Fixed roles and the public role can't be removed.

A role can't be removed if it owns any securables. Before dropping an application role that owns securables, you must first transfer ownership of the securables, or drop them. Use ALTER AUTHORIZATION to change the owner of objects that must not be removed.

sp_droprole can't be executed within a user-defined transaction.

Permissions

Requires CONTROL permission on the role.

Examples

The following example removes the application role Sales.

EXEC sp_droprole 'Sales';
GO

Related content