Solved

script synchronize server permission between two servers

Posted on 2015-02-02
4
43 Views
Last Modified: 2015-02-17
Hello,

I search a script to synchronize or get server permission (example grant view server state) between two servers.

Thanks
0
Comment
Question by:bibi92
  • 2
4 Comments
 
LVL 47

Expert Comment

by:Vitor Montalvão
ID: 40585883
Please tell us more about this question. Like this we can't do nothing but guess what's going in your mind.
0
 

Author Comment

by:bibi92
ID: 40586127
Hello,

I search how to generate Grant All User to view Server State from all users.

Thanks

Regards
0
 
LVL 47

Expert Comment

by:Vitor Montalvão
ID: 40586151
You can give that permission to PUBLIC so any user that connect to SQL Server will have that permission:
GRANT VIEW SERVER STATE TO PUBLIC

Open in new window

0
 
LVL 42

Accepted Solution

by:
EugeneZ earned 500 total points
ID: 40587520
try

this below script from
http://www.kendalvandyke.com/2009/01/scripting-server-permissions-and-role.html


and read \use code for "copy login" additional steps that you may like to have as well

http://www.databasejournal.com/features/mssql/article.php/3922256/Re-generating-SQL-Server-Logins.htm
Re-generating SQL Server Logins

SET NOCOUNT ON 

SELECT  'USE' + SPACE(1) + QUOTENAME('MASTER') AS '--Database Context' 

-- Role Members 
SELECT  'EXEC sp_addsrvrolemember @rolename =' + SPACE(1) 
        + QUOTENAME(usr1.name, '''') + ', @loginame =' + SPACE(1) 
        + QUOTENAME(usr2.name, '''') AS '--Role Memberships' 
FROM    sys.server_principals AS usr1 
        INNER JOIN sys.server_role_members AS rm ON usr1.principal_id = rm.role_principal_id 
        INNER JOIN sys.server_principals AS usr2 ON rm.member_principal_id = usr2.principal_id 
ORDER BY rm.role_principal_id ASC 

-- Permissions 
SELECT  server_permissions.state_desc COLLATE SQL_Latin1_General_CP1_CI_AS 
        + ' ' + server_permissions.permission_name COLLATE SQL_Latin1_General_CP1_CI_AS 
        + ' TO [' + server_principals.name COLLATE SQL_Latin1_General_CP1_CI_AS 
        + ']' AS '--Server Level Permissions' 
FROM    sys.server_permissions AS server_permissions WITH ( NOLOCK ) 
        INNER JOIN sys.server_principals AS server_principals WITH ( NOLOCK ) ON server_permissions.grantee_principal_id = server_principals.principal_id 
WHERE   server_principals.type IN ( 'S', 'U', 'G' ) 
ORDER BY server_principals.name, 
        server_permissions.state_desc, 
        server_permissions.permission_name 

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question