This SQL Server tutorial explains how to use the SESSION_USER function in SQL Servers (Transact-SQL) with syntax and examples.
Description
In SQL Server (Transact-SQL), the SESSION_USER function returns the user name of the current session in the SQL Server database.
Syntax
The syntax for the SESSION_USER function in SQL Servers (Transact-SQL) is:
SESSION_USER
Parameters or Arguments
identification_number
Optional. The identification number associated with a user in SQL Server.
Note
- Do not put parentheses () after the SESSION_USER function.
- See also the CURRENT_USER, USER_NAME, SYSTEM_USER functions.
Applies To
The SESSION_USER function can be used in the following versions of SQL Server (Transact-SQL):
- SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005
Example
Let’s look at some SQL Server SESSION_USER functions examples and explore how to use the SESSION_USER function in SQL Server (Transact-SQL).
For example:
SELECT SESSION_USER; Result: 'dbo'
Pingback: SQL Server: CURRENT_USER function - Adglob Infosystem Pvt Ltd