USER_NAME

USER_NAME is a function in SQL Server. It returns the database username based on the specified user's ID. If no parameter is provided, it returns the name of the current user.

USER_NAME()

Example

SELECT USER_NAME();

Output

dbo

Explanation

The USER_NAME() function in SQL Server returns the database user name based on the specified user ID. If the user ID is not specified, the function will return the name of the current user. In this case, the output ‘dbo’ represents the database owner.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.