sp_addsrvrolemember (Transact-SQL)
Adds a login as a member of a fixed server role.
Important
This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Use ALTER SERVER ROLE instead.
Transact-SQL Syntax Conventions
Syntax
sp_addsrvrolemember [ @loginame= ] 'login'
, [ @rolename = ] 'role'
Arguments
[ @loginame = ] 'login'
Is the name of the login being added to the fixed server role. login is sysname, with no default. login can be a SQL Server login or a Windows login. If the Windows login has not already been granted access to SQL Server, access is automatically granted.[ @rolename = ] 'role'
Is the name of the fixed server role to which the login is being added. role is sysname, with a default of NULL, and must be one of the following values:sysadmin
securityadmin
serveradmin
setupadmin
processadmin
diskadmin
dbcreator
bulkadmin
Return Code Values
0 (success) or 1 (failure)
Remarks
When a login is added to a fixed server role, the login gains the permissions associated with that role.
The role membership of the sa login and public cannot be changed.
Use sp_addrolemember to add a member to a fixed database or user-defined role.
sp_addsrvrolemember cannot be executed within a user-defined transaction.
Permissions
Requires membership in the role to which the new member is being added.
Examples
The following example adds the Windows login Corporate\HelenS to the sysadmin fixed server role.
EXEC sp_addsrvrolemember 'Corporate\HelenS', 'sysadmin';
GO
See Also
Reference
Security Stored Procedures (Transact-SQL)
sp_addrolemember (Transact-SQL)
sp_dropsrvrolemember (Transact-SQL)
System Stored Procedures (Transact-SQL)
Security Functions (Transact-SQL)