SQL Server USER_NAME() Function
SQL Server USER_NAME() Function
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
Return the database user name (will return the current user since no id is specified):
SELECT USER_NAME();
Try it Yourself »
https://www.w3schools.com/sql/func_sqlserver_user_name.asp 1/8
1/22/25, 6:02 PM SQL Server USER_NAME() Function
If no id is specified, this function will return the name of the current user.
Tutorials Exercises Certificates Services Sign Up Log in
Syntax
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
USER_NAME(id_number)
Parameter Values
Parameter Description
Technical Details
Works in: SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse,
Parallel Data Warehouse
More Examples
Example
Return the database user name with id 1:
SELECT USER_NAME(1);
https://www.w3schools.com/sql/func_sqlserver_user_name.asp 2/8
1/22/25, 6:02 PM SQL Server USER_NAME() Function
Try it Yourself »
Tutorials Exercises Certificates Services Sign Up Log in
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
ADVERTISEMENT
https://www.w3schools.com/sql/func_sqlserver_user_name.asp 3/8
1/22/25, 6:02 PM SQL Server USER_NAME() Function
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
https://www.w3schools.com/sql/func_sqlserver_user_name.asp 4/8
1/22/25, 6:02 PM SQL Server USER_NAME() Function
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
COLOR PICKER
ADVERTISEMENT ADVERTISEMENT
https://www.w3schools.com/sql/func_sqlserver_user_name.asp 5/8
1/22/25, 6:02 PM SQL Server USER_NAME() Function
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
https://www.w3schools.com/sql/func_sqlserver_user_name.asp 6/8
1/22/25, 6:02 PM SQL Server USER_NAME() Function
C++ Tutorial Angular Reference
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate
https://www.w3schools.com/sql/func_sqlserver_user_name.asp 7/8
1/22/25, 6:02 PM SQL Server USER_NAME() Function
Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP R
https://www.w3schools.com/sql/func_sqlserver_user_name.asp 8/8