• Hi Mark,

    Thanks for the feedback! I should have pointed out this was for Windows authenticated logins, not SQL logins, which follow a different format.

    I got the idea for this function from a post. Someone was looking to convert and compare to SID's in AD.

    It could be used for troubleshooting login problems with Windows logins.

    Here's an example that would show where a domain account might have been deleted and recreated. By comparing the RID's it's easy to see, or rule out, that type of problem.

    PSGETSID \\MYDC1 User1 \\MYDC2 User1

    Returns: S-1-5-21-19403481-1134232155-530107130-3978

    Then you check sys.server_principals on the SQL Server.

    SELECT name, dbo.fn_SIDToString(sid) from sys.server_principals.

    Returns: User1, S-1-5-21-19403481-1134232155-530107130-3953

    Edit: added 'User1' to second part of example.