Tuesday, 1 March 2011
How do I Transfer logins from one SQL Server 2005 instance to another?
http://support.microsoft.com/kb/918992/ - Folllow the procedure from microsoft.
USE master
GO
CREATE PROCEDURE sp_hexadecimal, sp_help_revlogin and get the output script from EXEC sp_help_revlogin in the primary server or old server or source server.
Once done, you have to synchronise the database users
Run the below script under the database where you want the users to synchronise:
DECLARE @UserName nvarchar(255)
DECLARE Cursor_OrphanedUser cursor for
SELECT NAME FROM sysusers WHERE issqluser = 1 and (sid is not null and sid <> 0x01) and suser_sname(sid) is NOT null ORDER BY name
OPEN Cursor_OrphanedUser
FETCH NEXT FROM Cursor_OrphanedUser INTO @UserName
WHILE (@@fetch_status = 0)
BEGIN
PRINT @UserName + ' Synchronization of Logins in Progress'
EXEC sp_change_users_login 'Update_one', @UserName, @UserName
FETCH NEXT FROM Cursor_OrphanedUser INTO @UserName
END
CLOSE Cursor_OrphanedUser
DEALLOCATE Cursor_OrphanedUser
Subscribe to:
Comments (Atom)

