Applies to: SQL Server
Adds a login as a member of a fixed server role.
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
sp_addsrvrolemember [ @loginame= ] 'login' , [ @rolename = ] 'role'
[ @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:
Return Code Values
0 (success) or 1 (failure)
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.
Requires membership in the role to which the new member is being added.
The following example adds the Windows login
Corporate\HelenS to the
sysadmin fixed server role.
EXEC sp_addsrvrolemember 'Corporate\HelenS', 'sysadmin'; GO
Security Stored Procedures (Transact-SQL)
System Stored Procedures (Transact-SQL)
Security Functions (Transact-SQL)
CREATE SERVER ROLE (Transact-SQL)
DROP SERVER ROLE (Transact-SQL)