Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » System FunctionsRSS Feeds

SESSION_USER Function

Posted By: Sarita Patel     Category: SQL Server     Views: 1692

This article explains about SESSION_USER function in sql server with examples.

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 

SELECT SESSION_USER

Output
dbo

Above example returns current session's user name.
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on SESSION_USER Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of SESSION_USER Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!