I have an orphan user in sql server and I want to get the login name not the user name because they are not the same, I didn't find a solution that correspond to my needs.

I believe that this is what you need:
SELECT ORIGINAL_LOGIN()
You should be able to get it using :
SELECT suser_name()
Docs Link : https://learn.microsoft.com/en-us/sql/t-sql/functions/suser-name-transact-sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With