THE WORLD'S LARGEST WEB DEVELOPER SITE

SQL Server USER_NAME() Function

❮ SQL Server Functions

Example

Return the user name in the SQL Server database:

SELECT USER_NAME();
Try it Yourself »

Definition and Usage

The USER_NAME() function returns the user name in the SQL Server database.

Syntax

USER_NAME(id_number)

Parameter Values

Parameter Description
id_number Optional. The identification number associated with a user in SQL Server

Technical Details

Works in: SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005

More Examples

Example

Return the user name in the SQL Server database:

SELECT USER_NAME(1);
Try it Yourself »

❮ SQL Server Functions