Events
Sep 15, 6 AM - Sep 17, 3 PM
The best SQL community-led learning event. Sept 2025. Save €200 with code FABLEARN.
Get registeredThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
SQL Server
Removes a database user from the current database.
Important
This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use DROP USER instead.
Transact-SQL syntax conventions
sp_revokedbaccess [ @name_in_db = ] N'name_in_db'
[ ; ]
The name of the database user to be removed. @name_in_db is sysname, with no default. @name_in_db can be the name of a server login, a Windows login, or a Windows group, and must exist in the current database. When you specify a Windows login or Windows group, specify the name by which it's known in the database.
0
(success) or 1
(failure).
When the database user is removed, the permissions and aliases that depend on the user are also removed.
sp_revokedbaccess
can remove only database users from the current database. Before removing a database user that owns objects in the current database, you must either transfer ownership of the objects or drop them from the database. For more information, see ALTER AUTHORIZATION.
sp_revokedbaccess
can't be executed within a user-defined transaction.
Requires ALTER ANY USER permission on the database.
The following example removes the database user mapped to Edmonds\LolanSo
from the current database.
EXEC sp_revokedbaccess 'Edmonds\LolanSo';
GO
Events
Sep 15, 6 AM - Sep 17, 3 PM
The best SQL community-led learning event. Sept 2025. Save €200 with code FABLEARN.
Get registeredPlease sign in to use this experience.
Sign in