Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Adds a login, or security principal, as a member of a fixed server role.
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 ALTER SERVER ROLE instead.
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 SQL Server login or a Windows account. If the Windows account isn't already granted access to SQL Server, 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:
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
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today