In this post explains how to use the SYSTEM_USER function in SQL Server (Transact-SQL) with syntax and examples.
Description
In SQL Server (Transact-SQL), the SYSTEM_USER function returns the login name information for the current user in the SQL Server database.
Syntax
The syntax for the SYSTEM_USER function in SQL Server (Transact-SQL) is:
Parameters or Arguments
There are no parameters or arguments for the SYSTEM_USER function.
Note
If the current user is logged into SQL Server using Windows Authentication, the SYSTEM_USER function will return the login name information in the following format: DOMAIN\user_name
If the current user is logged into SQL Server using SQL Server Authenication, the SYSTEM_USER function will return the login name information in the following format: user_name
Do not put parentheses () after the SYSTEM_USER function.