USER_ID returns login identification name from a user's security identification number (SID).
USER_ID can be used in the select list, in the WHERE clause, and anywhere an expression is allowed.
Syntax of USER_ID Function :
USER_ID ( [ 'user' ] )
user is a username. It is of type nchar. It is an optional. If you don't specify the current user is assumed.
Return type of USER_ID is a smallint.
Examples of USER_ID Function :
Example 1 : Use of USER_ID function in select clause
SELECT
USER_ID ('NorthwindUser
')
Output
6
Above example returns NorthwindUser user's database id number.