15 October,2014 by Jack Vamvas
Question : How can I script database role permissions? I’ve created the database role but need to migrate the database role permissions.
Answer: Use this DBA script on the source database . Add the database role name as a value to the @DBRoleName variable.Copy and paste the GRANT EXECUTE statements and execute them on the target database
declare @DBRoleName varchar(40) = 'myDatabaseRole' SELECT 'GRANT ' + dbprm.permission_name + ' ON ' + OBJECT_SCHEMA_NAME(major_id) + '.' + OBJECT_NAME(major_id) + ' TO ' + dbrol.name + char(13) COLLATE Latin1_General_CI_AS from sys.database_permissions dbprm join sys.database_principals dbrol on dbprm.grantee_principal_id = dbrol.principal_id where dbrol.name = @DBRoleName
SQL Server database roles and GDPR
SQL Database roles and members
Powershell sql server security audit - SQL Server DBA
How to create a SQL Server Security Audit - SQL Server DBA
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |