Return the user name of the current context in the current database.
Syntax SESSION_USER
Use this function with DEFAULT Table Constraints to automatically populate a column.
Examples
SELECT CONVERT(char(20), SESSION_USER); SELECT 'The current user is: '+ SESSION_USER; CREATE TABLE ptr
(
ptr_id int IDENTITY(5000, 1) NOT NULL,
ptr_text char(100),
entered_by_user nchar(20) NOT NULL DEFAULT SESSION_USER
)
"Every man has a right to risk his own life for the preservation of it" ~ Jean Jacques Rousseau, The Social Contract
Related commands:
SYSTEM_USER
- Windows login name
USER
/ USER_NAME / CURRENT_USER - name of the current user