pdiddy
pdiddy

Reputation: 6297

SQL USER_NAME() windows authentication

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

SELECT USER_NAME()

I see the result as dbo.

I would of thought that it would showed my user ....

I more looking at the explaination to as why it returns dbo

Upvotes: 3

Views: 3914

Answers (3)

Gomes
Gomes

Reputation: 3330

i had similar problem, the problem is due to the way user id is created.

choose the login id under security -> right click properties -> Server Roles. Ensure you click only "Public" no "sysadmin"

Upvotes: 2

Zamboni
Zamboni

Reputation: 8043

Try:

SELECT SUSER_SNAME()

Upvotes: 3

Martin Smith
Martin Smith

Reputation: 453658

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.

Upvotes: 8

Related Questions