SQL Server SESSION_USER Function
The SQL Server (Transact-SQL) SESSION_USER function returns the user name of the current session in the SQL Server database.
Syntax
SESSION_USER
Parameters
No parameter is required.
Return Value
Returns the user name of the current session in the SQL Server database.
Example:
The example below shows the usage of SESSION_USER function.
SELECT SESSION_USER;
The above query will return the user name of current session in the SQL Server database. Therefore if the SQL Server account that was used was 'za108909', it will return the following:
SELECT SESSION_USER; Result: 'za108909'
❮ SQL Server Functions