Tuesday, 17 November 2020

script to check the role for users in sqlserver:



SELECT 'EXEC sp_AddRoleMember ''' + DBRole.NAME + ''', ''' + DBUser.NAME + '''' AS '--Add Users to Database Roles--'

FROM sys.database_principals DBUser

INNER JOIN sys.database_role_members DBM ON DBM.member_principal_id = DBUser.principal_id

INNER JOIN sys.database_principals DBRole ON DBRole.principal_id = DBM.role_principal_id

No comments:

Post a Comment

Featured post

duplicate db from standy to other server

 Duplicate Testuat   $ export ORACLE_SID=Testuat3 $ sqlplus '/as sysdba' Testuat3 SQL> alter system set cluster_database=FALSE sc...