Here is a stored procedure that transfers the accounts and passwords to another server. It uses linked servers. After it has successfully run, you can then run sp_change_users_login to fix the accounts. Just create a linked server on the source server pointing to the destination server. Then modify the below stored procedure so that it references this linked server. I have added the default database option to sp_addlogin but it can be removed. Once modifications are done, just run the stored procedure on the source server after the database has been restored. Then run sp_change_users_login on the destination server. This stored procedure also checks if the login account already exists. If it does, synchronize the password by dropping the account then recreating it using the one on the source server.CREATE PROCEDURE isp_Transfer_LoginsASSET NOCOUNT ONDECLARE @login sysnameDECLARE @pwd sysnameDECLARE @new_pwd varchar(255)DECLARE cur_Users CURSOR FORSELECT l.name, l.passwordFROM master.dbo.syslogins lINNER JOIN DTS.dbo.sysusers u ON l.sid = u.sidWHERE (l.isntname = 0) AND (u.islogin = 1 AND u.isaliased = 0 AND u.hasdbaccess = 1)ORDER BY u.nameOPEN cur_UsersFETCH cur_Users INTO @login, @pwdWHILE @@FETCH_STATUS = 0BEGIN -- If the login does not exist on the destination server, then add it. IF ((SELECT count(*) FROM DestinationServer.master.dbo.syslogins WHERE name = @login) = 0) BEGIN EXEC DestinationServer.master.dbo.sp_addlogin @loginame = @login, @passwd = @pwd, @encryptopt = skip_encryption, @defdb = 'DBName' END -- If the login does exist on the destination server, then synchronize the password. ELSE BEGIN EXEC DestinationServer.master.dbo.sp_droplogin @login EXEC DestinationServer.master.dbo.sp_addlogin @loginame = @login, @passwd = @pwd, @encryptopt = skip_encryption, @defdb = 'DBName' END FETCH cur_Users INTO @login, @pwdENDCLOSE cur_UsersDEALLOCATE cur_UsersRETURN
Tara