user_name

Description

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

Syntax

user_name([user_id])

Parameters

user_id

is the ID of a user.

Examples

Example 1

select user_name()
------------------------------ 
dbo 

Example 2

select user_name(4)
------------------------------
margaret

Usage

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

You must be a System Administrator or System Security Officer to use this function on a user_id other than your own.

See also

Functions suser_name, user_id