Are the permissions in QA different from PROD? sp_helprevlogin will generate a script to recreate all logins to the server with their existing passwords (hashed) but it will not script the permissions in the database. If the permissions are different in QA than in PROD you probably need to script the permissions in QA first using something like this: http://vyaskn.tripod.com/scripting_permissions_in_sql_server_2005.htmIf the permissions in PROD are the correct ones you can basically do the backup/restore and then run an "unorphan"-script like this: DECLARE @SQL VARCHAR(1000), @SuccessCount INT, @ErrorCount INTSET @SuccessCount = 0SET @ErrorCount = 0 DECLARE curSQL CURSOR FOR SELECT 'EXEC sp_change_users_login ''UPDATE_ONE'', ''' + name + ''', ''' + name + '''' FROM sysusers WHERE issqluser = 1 AND name NOT IN ('guest', 'dbo', 'sys', 'INFORMATION_SCHEMA') OPEN curSQL FETCH curSQL INTO @SQL WHILE @@FETCH_STATUS = 0BEGIN BEGIN TRY EXEC (@SQL) SET @SuccessCount = @SuccessCount + 1 END TRY BEGIN CATCH SET @ErrorCount = @ErrorCount + 1 END CATCH FETCH curSQL INTO @SQLEND CLOSE curSQLDEALLOCATE curSQLRAISERROR (N'%d of the Logins were unorphaned successfully, %d logins don''t exist in the current master database', 1, 1, @SuccessCount, @ErrorCount)
- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com