Below Script is to copy one particular database role from one SQL server to another
declare @RoleName varchar(50) = ‘Database_Role_Name’
declare @Script varchar(max) = ‘CREATE ROLE ‘ + @RoleName + char(13)
select @script = @script + ‘GRANT ‘ + prm.permission_name + ‘ ON ‘ + OBJECT_NAME(major_id) + ‘ TO ‘ + rol.name + char(13) COLLATE Latin1_General_CI_AS
from sys.database_permissions prm
join sys.database_principals rol on
prm.grantee_principal_id = rol.principal_id
where rol.name = @RoleName
print @script
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTEXPERTS is always active on below social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform
Gayatri
Having a nice Information
Bhavanishankar
Good stuff
sai
useful post