Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL USER_NAME() windows authentication

Tags:

sql-server

When I log in sql management studio with windows authentication and I run

SELECT USER_NAME()

I see the result as dbo.

I expected it would show my user.

I am looking for an explanation as to why it returns dbo.

like image 332
pdiddy Avatar asked Jun 13 '26 12:06

pdiddy


1 Answers

Use this instead

SELECT SUSER_NAME()

USER_NAME: Returns a database user name from a specified identification number.

SUSER_NAME: Returns the login identification name of the user.

like image 136
Martin Smith Avatar answered Jun 18 '26 01:06

Martin Smith



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!