Returns the name within the database of the specified user or of the current user.
user_name([user_id])
select user_name()
------------------------------ dbo
select user_name(4)
------------------------------ margaret
If the sa_role is active, you are automatically the database dwner in any database you are using. Inside a database, the user_name of the database dwner is always “dbo”.
See also Transact-SQL Users Guide.
ANSI SQL – Compliance level: Transact-SQL extension.
You must be a user with sa_role or sso_role to use this function on a user_id other than your own.