Promotic
WikipediaLinkedInYoutubeTwitterFacebook

sp_addrolemember - statement of language DB_MSSQL

Description:
Add an account as a database role member of the SQL Server in the current database. Then the account gets rights connected with the appropriate role in the SQL Server.
Syntax:

sp_addrolemember

  [ @rolename = ] 'role'

  [ @membername = ] 'security_acount'

 
@rolename Database role of the SQL Server into which the account will be added (db_ddladmin, db_datareader, db_datawriter).
@membername Account created in the certain database (sp_grantdbaccess) that will be added into the database role.
Note:
The database role holds for the certain database. The fixed role of the SQL Server holds globally in the SQL Server.
Example:
Add the account 'pm_reader' into the database role of the SQL Server 'db_datareader' (then this account can be used for reading data of the appropriate database).
USE pm_data
EXEC sp_addrolemember 'db_datareader', 'pm_reader'
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice