Logo 
Search:

SQL Server Articles

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

SYSTEM_USER Function

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

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

SYSTEM_USER function allows a system-supplied value for the current system username to be inserted into a table when no default value is specified.

Use the SYSTEM_USER niladic function with DEFAULT constraints in either the CREATE TABLE or ALTER TABLE statements, or use as any standard function.

If the current user is logged in to SQL Server using Windows Authentication, SYSTEM_USER returns the Windows 2000 or Windows NT 4.0 login identification name, for example, DOMAIN\user_login_name. 

If the current user is logged in to SQL Server using SQL Server Authentication, SYSTEM_USER returns the SQL Server login identification name, for example, sa for a user logged in as sa.



Syntax of SYSTEM_USER Function :

SYSTEM_USER

Return type of SYSTEM_USER function is a nchar.




Examples of SYSTEM_USER Function :

Example 1 : Use of SYSTEM_USER function in select clause 

SELECT SYSTEM_USER

Output
machine-PC\machine

Above example returns current system user name.
  
Share: 


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

Sarita Patel
Sarita Patel author of SYSTEM_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!