I would like to roll-up permissions. Is it possible to add a role as a member of another role in a Microsoft SQL Server 2016 database? If so, then how?
Yes, it is possible. simply by using sp_addrolemember, or the GUI as you'd normally add a user to a role:
ALTER ROLE 'BigRole' ADD MEMBER 'LittleRole'
Note that SQL Server will prevent you from making a role a member of itself, so if "BigRole" is already a member of "LittleRole", the above will fail.
-
1A word of caution; sp_addrolemember is officially deprecated and the documentation recommends that you avoid it for new development. docs.microsoft.com/en-us/sql/relational-databases/… – krystah Mar 25 '19 at 10:24
-
1Using a non-deprecated syntax:
ALTER ROLE [db_datareader] ADD MEMBER [MyCustomRole]
– Gabe Oct 12 '20 at 16:30