Script Server Roles

  • Rasmus Glibstrup

    SSC Enthusiast

    Points: 121

    Comments posted to this topic are about the item Script Server Roles

  • andrei_solntsev

    SSCommitted

    Points: 1653

    Hi Rasmus,

    it is possibly to simplify your script up to one select statement ;-):

    SELECT 'EXEC sp_addsrvrolemember '''+pr.name+''', '''+pm.name+''''

    FROM sys.server_role_members AS rm

    JOIN sys.server_principals AS pm ON rm.role_principal_id=pm.principal_id

    JOIN sys.server_principals AS pr ON rm.member_principal_id=pr.principal_id

    WHERE pr.name <> 'sa'

    AND pr.name NOT LIKE 'NT SERVICE%'

    AND pr.name NOT LIKE 'NT AUTHORITY%'

    Kind regards,

    Andrei

  • Jon.Morisi

    SSChampion

    Points: 12846

    Thank You!

    --First Create sp_help_revlogin and use it to migrate logins

    --Second run this to update the server roles

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    Thanks for the script.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply