SESSION_USER function allows a system-supplied value for the current session's username to be inserted into a table when no default value is specified. Also allows the username to be used in queries, error messages etc.
Use SESSION_USER with DEFAULT constraints in either the CREATE TABLE or ALTER TABLE statements, or use as any standard function.
Syntax of SESSION_USER Function :
SESSION_USER
Return type of SESSION_USER function is a nchar.
Examples of SESSION_USER Function :
Example 1 : Use of SESSION_USER function in select clause
Output
dbo
Above example returns current session's user name.