orphaned Users

  • hi can you please any one tell me what is exactly orphaned users and when will use this one and how to troubleshoot?

    Thanks in Advance.

    Regards,

    Raja.

  • Attaching and restoring databases from one server instance to another are common tasks executed by a DBA.If we move our database to another SQL Server instance through any process, the new server might or might not have the same logins and the SIDs of these logins would probably be different from the SIDs of these logins in the original server. What this means is that, the sysusers table in the moved database has SIDs that are not matched with the login info in the master database on this new server. Therefore we get orphaned users

    Once the Database is restored on the new instance. Run the below commands to troubleshoot and fix the issue.

    -Command to generate list of orphaned users

    USE <DBNAME>

    GO

    sp_change_users_login @Action='Report'

    GO

    --Command to map an orphaned user

    EXEC sp_change_users_login 'Auto_Fix', '<Username>'

    GO

    If a login name does not exists, you would have to create it first before doing the mapping. A quick way to do this is to use the following command which will create the login and then map the login to the user

    --Command to map an orphaned user to a login that is not present but will be created

    EXEC sp_change_users_login 'Auto_Fix', '<Username>', null,'<pwd>'

    GO

  • brangaraja (1/2/2013)


    hi can you please any one tell me what is exactly orphaned users and when will use this one and how to troubleshoot?

    For details see this link http://www.mssqltips.com/sqlservertip/1590/understanding-and-dealing-with-orphaned-users-in-a-sql-server-database/

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • Rama Chandra Gowtham. Peddada (1/2/2013)


    Attaching and restoring databases from one server instance to another are common tasks executed by a DBA.If we move our database to another SQL Server instance through any process, the new server might or might not have the same logins and the SIDs of these logins would probably be different from the SIDs of these logins in the original server. What this means is that, the sysusers table in the moved database has SIDs that are not matched with the login info in the master database on this new server. Therefore we get orphaned users

    Once the Database is restored on the new instance. Run the below commands to troubleshoot and fix the issue.

    -Command to generate list of orphaned users

    USE <DBNAME>

    GO

    sp_change_users_login @Action='Report'

    GO

    --Command to map an orphaned user

    EXEC sp_change_users_login 'Auto_Fix', '<Username>'

    GO

    If a login name does not exists, you would have to create it first before doing the mapping. A quick way to do this is to use the following command which will create the login and then map the login to the user

    --Command to map an orphaned user to a login that is not present but will be created

    EXEC sp_change_users_login 'Auto_Fix', '<Username>', null,'<pwd>'

    GO

    you need to give credit to the main poster/blogger OR even paste his/her link.These are forum etiquettes 🙂

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • Also remember that sp_change_users_login is a depreciated command, it has been replaced by ALTER LOGIN and will be removed from a future release on SQL.

  • I hope this link will help you..

    http://sqlscripthub.blogspot.in/2012/11/sqlworld.html

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply