title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | f1_keywords | helpviewer_keywords | dev_langs | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sp_addsrvrolemember (Transact-SQL) |
sp_addsrvrolemember adds a security principal as a member of a fixed server role. |
markingmyname |
maghan |
randolphwest |
01/23/2024 |
sql |
system-objects |
reference |
|
|
|
[!INCLUDE SQL Server]
Adds a login, or security principal, as a member of a fixed server role.
Important
[!INCLUDE ssNoteDepFutureAvoid] Use ALTER SERVER ROLE instead.
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_addsrvrolemember
[ @loginame = ] N'loginame'
[ , [ @rolename = ] N'rolename' ]
[ ; ]
The name of the security principal being added to the fixed server role. @loginame is sysname, with no default. @loginame can be a [!INCLUDE ssNoVersion] login or a Windows account. If the Windows account isn't already granted access to [!INCLUDE ssNoVersion], access is automatically granted.
The name of the fixed server role to which the security principal is being added. @rolename is sysname, with a default of NULL
, and must be one of the following values:
- sysadmin
- securityadmin
- serveradmin
- setupadmin
- processadmin
- diskadmin
- dbcreator
- bulkadmin
0
(success) or 1
(failure).
When a security principal is added to a fixed server role, it gains the permissions associated with that role.
The role membership of the sa user and public can't be changed.
Use sp_addrolemember
to add a member to a fixed database or user-defined role.
sp_addsrvrolemember
can't 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 account Corporate\HelenS
to the sysadmin fixed server role.
EXEC sp_addsrvrolemember 'Corporate\HelenS', 'sysadmin';
GO