Recreating Permissions from 1 server to another for a different group
The second script I am going to post is used to copy all the permissions in all databases for a login matching the pattern and generating the GRANT permissions for a different login. You could swap out the REPLACE line with just the [dbprinc].[name] if you want the same group to have them assigned on a different server. I used this to migrate permissions to both DEV and TEST for 3 servers. All told, it generated about 19,000 rows between them. Imagine having to copy those manually.  /***********************************************/ /*************       START CODE       ***************/ /***********************************************/ DECLARE @DBName 			 VARCHAR (500) , @sqltext 				 NVARCHAR(MAX) SELECT 					 @DBName 				 = 	 '' SELECT 					 @sqltext 					 = 	 '' IF OBJECT_ID('[tempdb]..#Perms') IS NOT NULL BEGIN 	 DROP TABLE #Perms END  CREATE TABLE #Perms ( 	 [PermString] 		 VARCHAR(MAX) ) DECLARE DBNames_Cursor CURSOR ...
Comments
Post a Comment