Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get login name in SQL SERVER

Tags:

sql

sql-server

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.

login name

like image 642
Hassan Avatar asked Dec 21 '25 14:12

Hassan


2 Answers

I believe that this is what you need:

SELECT ORIGINAL_LOGIN()
like image 179
Bartosz X Avatar answered Dec 24 '25 02:12

Bartosz X


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

like image 43
Andrew Avatar answered Dec 24 '25 02:12

Andrew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!