How to find orphaned user and aliased SQL Login with t-sql

  • I have an orphaned user, but when I view the user properties in SSMS the General tab shows a Login name, that does not match the User name.

    See below:

    Screenshot 2024-03-27 161213

     

    This SQL Login name does not exist in the SQL Login in sys.server_principals as the SQL Login was dropped from the SQL Instance.

    I have tried to find the t-sql that will list out the above Login name. Can someone point me to which system view contains the Login name?

     

  • View sys.database_principals will have the sid of the login (but not the login name itself).  View sys.server_principals also has a sid.

    If the login has been dropped, the sid may still be there but not link back to any active login.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

Viewing 2 posts - 1 through 1 (of 1 total)

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