user_name

Returns the name within the database of the specified user or of the current user.

Syntax

user_name([user_id])

Parameters

Examples

Usage

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.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

You must be a user with sa_role or sso_role to use this function on a user_id other than your own.

Related reference
suser_name
user_id