sp_revokedbaccess (Transact-SQL)
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
Syntax
sp_revokedbaccess [ @name_in_db = ] 'name'
Arguments
[ @name_in_db = ] 'name'
Is the name of the database user to be removed. name is a sysname with no default. name 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 is known in the database.
Return Code Values
0 (success) or 1 (failure)
Remarks
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 (Transact-SQL).
sp_revokedbaccess cannot be executed within a user-defined transaction.
Permissions
Requires ALTER ANY USER permission on the database.
Examples
The following example removes the database user mapped to Edmonds\LolanSo
from the current database.
EXEC sp_revokedbaccess 'Edmonds\LolanSo';
GO
See Also
Security Stored Procedures (Transact-SQL)
System Stored Procedures (Transact-SQL)
DROP USER (Transact-SQL)
ALTER AUTHORIZATION (Transact-SQL)
Phản hồi
https://aka.ms/ContentUserFeedback.
Sắp ra mắt: Trong năm 2024, chúng tôi sẽ dần gỡ bỏ Sự cố với GitHub dưới dạng cơ chế phản hồi cho nội dung và thay thế bằng hệ thống phản hồi mới. Để biết thêm thông tin, hãy xem:Gửi và xem ý kiến phản hồi dành cho